If you have access to a PC with a fast network connection, and you can install a web page and a perl CGI script on it, then you can stream Hulu videos on any Android machine (phone, tablet, whatever). It works better if you have root on your device...
First, some explanation. You probably don't need to understand this perfectly, and the actual scripts are no-brainers to use, but I think it's better to know why it works before doing it.
Hulu streams videos using Adobe's non-standard, proprietary RTMP protocol. Android phones (actually, most smart phones) have built in support for RTSP, an Internet Standard protocol. The two protocols are totally incompatible. While RTMP is built in to Adobe Flash clients, you don't actually need Flash to be able to use RTMP. Thanks to the RTMPDump project, you can stream RTMP videos on any machine, regardless of CPU type or operating system. (But installing rtmpdump on Android requires root access, and we don't actually require root access for this HowTo.)
RTMPDump started out as a self-contained program, but it has since been split apart into a library and a set of utility programs. The library has been integrated into other projects like ffmpeg, mplayer, XBMC, gstreamer, curl, and VLC, allowing them to support RTMP access along with whatever other protocols they supported before.
In this HowTo I'm focusing on the ffserver program, which is part of the ffmpeg project. ffserver has the ability to serve video streams over HTTP and RTSP. When built with RTMPDump's librtmp, it also has the ability to fetch streams over RTMP. So, we can set up an ffserver to act as a gateway, pulling RTMP streams from Hulu (or any other video site) and re-broadcast them over RTSP, which any Android device can play.
While this is generally pretty straightforward, there are several potential gotchas along the way.
video codec - Android supports H.264 Baseline Profile, along with the older MPEG4 codec. Hulu uses VP6 on older programs, and H.264 Main Profile. (I'm told that some Android devices also support H.264MP, but my G1 definitely does not.)
video resolution - My G1 won't play anything larger than 480x320, while the smallest Hulu videos are 512x288 or 512x384.
network support - Works great over WiFi, but it seems to me that T-Mobile blocks RTSP/RTP traffic on EDGE and 3G.
The two video issues can easily be addressed by using ffmpeg to transcode the video from Hulu into a format that the Android device can handle. For the network issue, you're either going to be stuck with only being able to use this over WiFi, or you're going to need root access to install a workaround on your Android device.
You'll need to have a recent build of ffmpeg and ffserver on your PC. And unfortunately, you're probably going to have to build these yourself, because as of the time of writing, the ffserver code is still partly broken. A patch has been available for a couple months now but the ffserver maintainers have yet to agree to commit it. You must apply the patch to the ffserver code before any of this will work. Also you need perl, and a number of additional perl modules.
After you've built and installed that, you'll need these scripts which actually grab the Hulu RTMP video and feed it to your ffserver. You'll also need this ffserver.conf file:
This is a file I've tailored for my G1. It defines two RTSP streams, one for "full" resolution, which is a 480x320 H.264BP stream at 400kbps. This is what I use when WiFi or 3G are available and working. The other is a "low" resolution stream, 256x192 at 100kbps. This is for EDGE/2G.
(By the way, ffserver supports RTSP with RTP over both TCP and UDP, but it looks like current versions of Android only use RTSP with RTP over UDP. This is unfortunate, because UDP streaming can lose a lot of packets over cellphone networks, and that will cause lots of glitches and dropouts in a video stream.)
A perl script is used to actually parse Hulu video URLs. It then invokes ffmpeg to fetch the video and feed the transcoded result to ffserver. The script runs as a CGI and returns a link that you can open in the Android browser, which will automatically launch the Android movie player and play the resulting video.
I've uploaded a short video demonstrating the script here
My mistake - T-Mobile isn't blocking RTP/UDP traffic, but their NAT/proxy will only recognize and handle it correctly it if the RTSP server is listening on the standard port, 554. I was using 5454 in my previous tests, and my local firewall was configured to pass that thru...
Bookmarks