Free Download

Site Search

 

Top Download

Tuesday, September 11, 2007

Open Source YouTube

Everyone knows what YouTube or Google Video is. Most of them might use to waste a period of time in this kind of service. I'm one of them. I also wonder how it works. Technically, upload video service like YouTube and Google Video is very similar in underlying technology. In particular, all uploaded videos are automatically converted to Flash Video or FLV. The FLVs are stored in the file server. However, the FLVs is nevered shown directly on your browser. Instead, the FLVs are played inside Flash Video Player written in Flash itself. As a result, you can view a video immediately after getting only some part of the full-length video. In other words, Flash Video Player and FLV are the best couple for on-demand video streaming.
If you think it is too complex and too difficult to implement XXXTube by yourself, I will summarize everything you need to know and to have.
You need a Flash Video Player,
Uploading system,
Video conversion system,
Big storage and
Bandwidth
Let's see how to implement XXXTube as fast as possible. For the first requirement, you don't need to write Flash Video Player by yourself. There is an open source project namely
Flash Video Player, latest verion is 2.4. The developer claimed that it has been used by YouTube and Blip. Next one, uploading system is very simple and easy. You can write uploading system in PHP in just an hour so you don't need to take care about this piece. The most difficult part of XXXTube is here in the third step, video conversion system. Why?
It should support video formats and codecs as many as possible or at least DivX, MPEG1, MPEG4, MOV, WMV, and 3GPP.
It might be as fast as possible. Otherwise, the uploaded videos may be waiting in the conversion queue. Nobody want this delay happened.
It should be robust and fully automatic. No interactive with other piece of tools.
Don't panic. Open source community is showing its useful, powerful, and awesome results. At least we have
FFmpeg, MPlayer, MEncoder, and Transcode. These are more than enough to produce flash video from various video formats and codecs.
The simplest example is shown in official documentation of MPlayer site.

mencoder input.avi \
-o output.flv \
-of lavf \
-oac mp3lame -lameopts abr:br=56 \
-ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 \
-srate 22050

Below is my flavorite.

mencoder input.avi \
-of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \
-ovc lavc
-lavcopts vcodec=flv:vbitrate=150 -ofps 15 \
-oac mp3lame -lameopts abr:br=32 -srate 22050 \
-vf scale=320:-3 \
-o output.flv

One last problem is how to handle mass clients to produce flv just in time.

Reference (sugree's blog)

No comments: