Results 1 to 3 of 3

Thread: How to watch Hulu on any Android device

  1. #1
    Join Date
    Dec 2004
    Posts
    72
    Device(s)
    Mot KRZR-K1
    Carrier(s)
    Verizon
    Feedback Score
    0

    How to watch Hulu on any Android device

    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.
    1. 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.)
    2. video resolution - My G1 won't play anything larger than 480x320, while the smallest Hulu videos are 512x288 or 512x384.
    3. 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.


    Still with me?

    OK. The patch is here:
    https://lists.mplayerhq.hu/pipermail...ne/090821.html

    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:

    Code:
    Port 8090
    RTSPPort 5454
    BindAddress 0.0.0.0
    MaxHTTPConnections 1000
    MaxClients 200
    MaxBandwidth 10000
    CustomLog -
    
    <Feed l.ffm>
    File /tmp/l.ffm
    FileMaxSize 2000M
    </Feed>
    
    <Feed f.ffm>
    # ffmpeg http://localhost:8090/f.ffm
    File /tmp/f.ffm
    FileMaxSize 2000M
    </Feed>
    
    <Stream 1>
    Format rtp
    Feed f.ffm
    
    NoLoop
    VideoCodec libx264
    VideoFrameRate 24
    VideoBitRate 400
    VideoSize 480x320
    AVPresetVideo default
    AVPresetVideo baseline
    AVOptionVideo flags +global_header
    
    AudioCodec libfaac
    AudioBitRate 64
    AudioChannels 2
    AudioSampleRate 44100
    AVOptionAudio flags +global_header
    
    </Stream>
    
    <Stream 3>
    Format rtp
    Feed l.ffm
    
    NoLoop
    
    VideoCodec libx264
    VideoFrameRate 24
    VideoBitRate 100
    VideoSize 256x192
    AVPresetVideo default
    AVPresetVideo baseline
    AVOptionVideo flags +global_header
    
    AudioCodec libfaac
    AudioBitRate 32
    AudioChannels 2
    AudioSampleRate 22050
    AVOptionAudio flags +global_header
    
    </Stream>
    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

    http://www.youtube.com/watch?v=F7lWLjtrbR0

    The script and web page are in the attachment.

    PS: I originally discussed all of this on the XDA Developers forum. You can get all the background story here:
    http://forum.xda-developers.com/show...=603539&page=4

    I'll talk about the root-only network access workaround in a followup if people are interested.
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2004
    Posts
    72
    Device(s)
    Mot KRZR-K1
    Carrier(s)
    Verizon
    Feedback Score
    0
    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...

  3. #3
    Join Date
    Mar 2005
    Posts
    1
    Feedback Score
    0
    this is awesome. anyone has any update on this effort on Android 2.2?

Similar Threads

  1. Replies: 4
    Last Post: 05-21-2010, 03:01 AM
  2. WTT Iphone 3g 8gb for Android device
    By simsballa23 in forum GSM phone Buy/Sell/Trade
    Replies: 0
    Last Post: 03-14-2010, 12:03 PM
  3. Can i stock rom touch pro watch justin.tv and Hulu?
    By crusader560 in forum Boost Mobile
    Replies: 5
    Last Post: 03-01-2010, 05:11 PM
  4. Motorola Android Device AT&T
    By Groot in forum Motorola
    Replies: 2
    Last Post: 01-06-2010, 11:59 PM
  5. I guess we're getting our Android device!!
    By dsjr2006 in forum AT&T
    Replies: 15
    Last Post: 12-14-2009, 09:06 PM

Tags for this Thread

Bookmarks