Search code examples
iosubuntuffmpegvideo-streaminghttp-live-streaming

How to implement HTTP Live Streaming server on Unix?


I just realized that Apple required HTTP Live Streaming in order to view videos in iPhone apps. I was not aware of this before... I am now trying to understand what this involves so I can decide whether I want to do the work and make the videos available in 3G or limit video playing to users who are connected to wi-fi.

I read the overview provided by Apple, and now understand that my server needs to segment and index my media files. I also understand that I don't have to host the content to be able to stream it (I can point to a video hosted somewhere else, right?).

What's not clear to me at this point is what to implement on my server (Ubuntu Hardy) to do the actual segmenting and indexing on the fly (once again, I do not host the videos I want to serve).

I found a link explaining how to install FFmpeg and X264, but I don't know if this is the best solution (since I have an Ubuntu server, I can't use the Apple Live Streaming tools, is it correct?). Also, I do not understand at which point my server knows that a video needs to be converted and starts the job...

Any feedback that could help me understand exactly what to do on the server side to be able to stream videos on my iPhone app in 3G would be greatly appreciated! (Oh, and just it makes any difference, my app back-end is in Rails)


Solution

  • If you want to stream live content from your webcam : FMLE ( flash media live encoder )

    If you want to stream static content (movie) : ffmpeg & xuggle

    red5:

    You media server could be red5 ( open-source and free) or FMS or wowza. But i used only red5, i don't know about the others. You can find red5 here.

    You server can be anywhere but you will need to open some port (1935 for rtmp at least ) , 5080 for "admin panel", you could see 9999 in the list. ( Check the doc ) Red5 is a media server in java, so you will need java jdk >= 1.6.

    Red5 1.0 RC can be found here. You can find a version for windows, osx or linux. I used the tarball version. Extract it and run "red5.sh". You should be able to access the admin at http://localhost:5080/ and you should also see a video being display. If not, something wrong and you can't go further until this is working.

    Stream with ffmpeg:

    You can find xuggle here and you can find more information about this here

    ffmpeg -i your_file.flv -re -acodec copy -vcodec copy -f flv rtmp://localhost_or_yourred5serverip/live/livestream
    

    Keep in mind that if you want to stream it on the web only flv and mp4 can be playing in flash player ( i think ). Once it's streaming you should be able to see it in the "admin panel" here. Connect to your server (rtmp://localhost/live/) and go to the view tab and put "livestream". You could use mplayer rtmp://localhost/live/livestream to see your video too.

    stream in a flash player:

    You can use flowplayer (with the rtmp plugin) or jwplayer.