One of the great things about OS X Leopard is that it comes with Apache installed out of the box. Apache is an open source carrier grade web server that you can use to host websites and so on but more importantly – from the point of view of the iPhone or iPod Touch – it supports byte range reading. What this means is that your humble Mac can function as a streaming video server on your WLAN for your iPhone or iPod Touch with a little bit of legwork and a little PHP app that I threw together.
So how do you do it?
Next we need to enable PHP. Although it’s installed with Leopard, the PHP module is disabled in Apache’s configuration by default. Let’s enable it – open a Terminal and type:
sudo nano -w /etc/apache2/httpd.conf
(Note that the ‘-w’ is important – it disable line wrapping). Press CTRL-W and type php5 then press return – the cursor should jump to the line that loads the PHP module:
#LoadModule php5_module libexec/apache2/libphp5.so
Delete the hash mark at the start of the line and then press CTRL-O to save the updated config, followed by CTRL-X to exit the Nano text editor. Back at the command prompt, we need to restart the Apache server:
sudo apachectl restart
Once you have some video, it’s time to test with your iPhone/Touch – connect your device to your WLAN and then open Safari and browse to http://yourdevice.local/~User/EasyStream/ (substitute ‘yourdevice’ for your Mac’s hostname and ‘User’ for the short form of your username). EasyStream should list the video in your EasyStream/Movies folder; tapping on one should cause QuickTime to open and after a short pause to buffer, your video should start playing.
Like most things, this trick has some pros and cons. First the pros – you no longer have to fill your iPhone/Touch up with videos; just stick them in your EasyStream folder instead. Secondly, if you forward port 80 on the outside of your firewall to your Mac’s IP, you can view your videos remotely provided you have a working internet connection for your device and know your public IP address (I’ve no idea how well this works over 3G). Finally, as our first test demonstrated, you can view the EasyStream pages in your ordinary browser – you can also view the videos (provided QuickTime is installed). The non-iPhone version of QuickTime downloads the entire video before it starts playing but you can fix that by ticking the ‘web optimised’ box in Handbrake before you start your conversion.
As far as cons go, I’ve built in a ‘compact view’ that breaks the videos into an alphabetical hierarchy but with lots of videos in your EasyStream/Movies folder, things could still become cumbersome. Secondly, there’s no way to bookmark where you are in a video, so if you stop playing something midway through and then go back, you’ll have to scrub through until you find where you where. Luckily the iPhone makes this relatively painless and it’s a worthwhile trade-off not to have to store the videos on your iPhone.