How-To Example Code

Mencoder

Sometimes its not possible to directly create an FLV file from a WMV, MOV, RV etc file, so first we must convert our source file to another format first, something easier to work with, such as a DVD AVI file.

To do this we need to create an AVI tempfile with Mencoder:

/path/to/mencoder -channels 6 -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf harddup -srate 48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=6000:keyint=15:acodec=ac3:abitrate=192:aspect=16/9 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ofps 30000/1001 '".$infile."' -o '".$avifile."'

In this version of mencoder we must set "-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames" due to the server configuration and the programs date. On another Media serving box we have (FreeBSD) we omit this option and the AVI will build without a problem.

From here we use Mencoder again to build the FLV from the newly created AVI file

/path/to/mencoder '".$avifile."' -o '".$outfile."' -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=250:autoaspect:acodec=mp3:abitrate=56 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=400:300 -srate 22050 -af lavcresample=22050

Of course you have to set the dimensions and audio sample rate as per your requirements.

Site hosted on Zoob Internet