Tuesday, May 14, 2013
If you have ever used an Apple iPhone or Apple TV, you are probably familiar with AirPlay. AirPlay is a way to stream content to an AirPlay compatible device like an Apple TV; it is similar to Google’s Chromecast. However, if you are running a modern Linux distribution, you cannot easily stream anything using the AirPlay protocol. Luckily, an open source tool called airstream has been created to do just that.
This installation step is specific to Fedora, but as long as your particular Linux distribution has a working Ruby environment, the airstream gem should install without a problem.
yum install avahi-compat-libdns_sd-devel rubygem-gem-nice-install
gem install airstream
If you are streaming files from your local computer,
airstream will start an HTTP server on TCP port 7000 to stream the file to the Apple TV. If you are streaming from a web URL, such as http://example.com/foo.mp4, the file will stream to the Apple TV from there. If you have iptables or firewalld running, be sure to open TCP port 7000.
Be sure to place the following rule above the last iptables rule in the INPUT chain (assuming the last entry in the INPUT chain is a REJECT rule).
iptables -A INPUT -m state --state NEW -p tcp --dport 7000 -j ACCEPT
Be sure to save the new iptables rules so it persists on iptables service restarts.
firewall-cmd --permanent --zone=public --add-port=7000/tcp && firewall-cmd --reload
Assuming the file you want to stream to the Apple TV is foo.mp4, use the
airstream command like so:
airstream -o apple-tv.example.com /path/to/foo.mp4
Assuming the file you want displayed on the Apple TV is foo.jpg, use the
airimg command like so:
airimg -o apple-tv.example.com /path/to/foo.jpg
You can also display many pictures in a slide show on the Apple TV by using a wild card with the
airimg command like so:
airimg -o apple-tv.example.com /path/to/*.jpg
An additional command line switch can be added to display pictures for particular lengths of time.
The expected behavior when displaying many pictures in a slide show is to show one picture after another without interruption, but I have seen situations where displaying many pictures in a slide show will show the picture, go back to the last thing displayed on the Apple TV, display the next picture, and rinse and repeat. I have not been able to figure out why this behavior happens and other times does not.