This page shows how easy it is to stream video to an out-of-the-box Apple TV. The script that can be downloaded here is aimed at the streams of the Dutch public-service television channels, but it is straightforward to extend to other streams.
The protocol for communicating with an Apple TV turns out to be rather simple. The Apple TV listens on port 7000 for incoming connections. Commands are sent in the form of HTTP requests.
For example, the following telnet session tells the Apple TV to play a video from example.org:
$ telnet apple-tv 7000
Trying 192.168.1.14...
Connected to apple-tv.home.
Escape character is '^]'.
POST /play HTTP/1.1
Content-Length: 65
User-Agent: MediaControl/1.0
Content-Location: http://example.org/test.mp4
Start-Position: 0
HTTP/1.1 200 OK
Date: Sat, 14 Apr 2012 12:43:34 GMT
Content-Length: 0
Now the Apple TV will download/buffer the specified file and start playing. As soon as the connection is closed, however, playback will stop. There also appears to be a timeout when the connection is idle for more than 10 seconds. To get around this, we can ask for updates of the playback position regularly:
GET /scrub HTTP/1.1
HTTP/1.1 200 OK
Date: Sat, 14 Apr 2012 12:43:52 GMT
Content-Type: text/parameters
Content-Length: 40
duration: 56.342961
position: 12.145932
For a detailed list of all the commands, see:
The Dutch website uitzendinggemist.nl provides a large archive of television programmes aired by the Dutch public-service broadcasting organization. Unfortunately, they only support playback on Apple TV via their iPhone/iPad app. There is no application for MacBooks or non-Apple systems.
Since there is no technical reason why such an application does not exist, I've decided to write a small Perl script that extracts the H.264/MPEG-4 stream from a given episode page and plays it on the Apple TV. Alternatively, it can also play Journaal24 and Politiek24 using the iPad streams.
To use the Perl script, first edit the script and set the variable $APPLE_TV at the top to the hostname or IP address where your Apple TV can be reached.
To view a show from Uitzendinggemist.nl:
./atv.pl http://www.uitzendinggemist.nl/afleveringen/1248545
To view Journaal24 or Politiek24:
./atv.pl http://nos.nl/nieuws/live/journaal24/
./atv.pl http://nos.nl/nieuws/live/politiek24/
To view any other H.264/MPEG-4 stream or video:
./atv.pl http://example.org/test.mp4