[MEncoder-users] Conversion to FLV, are my settings optimal?

David Smith dcsmith2 at gmail.com
Thu Dec 4 16:48:07 CET 2008


>
> I am writing a desktop video uploader application that allows the user to
> upload any movie to the video section of our website. The web-player is
> made
> in flash, like on YouTube. So the output format must be flv, and not too
> big
> to avoid overloading the server. These are the settings that I use
> currently:
>
>
> input.avi
>
> -ofps 12
>
> -o mp3lame
>
> -lameopts abr:br=56
>
> -of lavf
>
> -srate 22050
>
> -vf softskip,decimate,pp7,scale=480:320,hqdn3d=4:3:6,harddup
>
> -ovc lavc
>
> -lavcopts
>
> keyint=15:vcodec=flv:vbitrate=256:mbd=2:v4mv:mv0:trell:vqcomp=1:vrc_eq=(tex+10^8*mcVar)^0.1:vstrict=-1
>
> -o output.flv
>
>
> Do you see any room for improvement here?
>
>
> I'd greatly appreciate any feedback.
>
>
> Thanks,
>
> Francis
> _______________________________________________
> MEncoder-users mailing list
> MEncoder-users at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mencoder-users


It really depends on your application, but if you are just doing video
convesion of typical file formats into FLV then your command line looks
way overly complicated.

The things that look like they can go away are:

*softskip,decimate,pp7,hqdn3d=4:3:6*

and

*mv0:vqcomp=1:vrc_eq=(tex+10^8*mcVar)^0.1:vstrict=-1
* You are just making your server work harder to convert the video for
almost no dicsernable improvement in video whatsoever. I have experimented
endlessly with mencoders Flash conversion, testing to see if some of these
random switches make any difference in quality and they don't, trust me.

What I have learned is that doing a 2-pass conversion is unequvilocally the
best way to go.  *You should be doing 2 pass*.  You will get the most
optimized file size, in combination with the best video quality.  This is
how YouTube does it.  I have been able to replicate YouTube's file size and
quality almost exactly using 2-pass.

If you know for sure that every video should be converted at vbitrate=256
then it's easy to do this programmatically.  The particular challenge I had
was that certain videos coming in might be super low quality (like .rm
files) or very high quality (.mov's).  So I had to set my vqscale to about
10, parse out the resulting bitrate, then stick that into the second pass
since the second pass has to have a fixed bitrate to make any sense using
it.  Fyi, I did all this on a PC using java.lang.Runtime under my app engine
(ColdFusion) to parse the results.

All that being said, here's the my basic command line syntax that I've found
yeilds really excellent results in terms of file size, quality and
processing time using the two pass scenario and a fixed rate:

PASS 1:
input.avi -o output.flv -oac mp3lame -lameopts q=9:mode=3 -srate 22050 -ovc
lavc -lavcopts
vcodec=flv:vbitrate=256:mbd=2:trell:v4mv:last_pred=3:vpass=1:turbo -mc 1
-ofps 30 -of lavf -vf harddup -nosound

PASS 2:
input.avi -o output.flv -oac mp3lame -lameopts q=9:mode=3 -srate 22050 -ovc
lavc -lavcopts vcodec=flv:vbitrate=256:mbd=2:trell:v4mv:last_pred=3:vpass=2
-mc 1 -ofps 30 -of lavf -vf harddup

Note that I am using -nosound on the first pass.  This speeds things up
considerably since you don't NEED to convert the audio twice.  Since
-nosound cancels the conversion I didn't bother removing the -oac line from
pass 1 (it might even be required but I forget).

The -ofps is really your choice.  For me 30 works great almost all the time.

I don't think you need to be using -softskip unless you plan to be using
advanced filters (inverse telecine, temporal denoising, etc.) or stuff with
DVDs.  For "regular" video formats it does not seem to make a difference
except to slow down the processing speed.

Also, you will notice I decided to use an audio quality level of 9 instead
of a fixed rate, and a mode=3 which is mono.  Let me just tell you that most
people watching video on the web cannot tell the difference between mono and
stereo, and this will in fact will get you a much smaller file size while
increasing your processing speed.  This was ultimately the way I was able to
get my converted files to be about the same size and quality as youtube.  If
you stay with stereo you will be doubling the audio portion of your file
size (if that matters to you).  In my case, I have to pay for every bit of
bandwidth used, so I was focused heavily on reducing file size, but of
course still keeping a high enough quality video.  Again, YouTube was my
benchmark.  You can do whatever.

I hope this helps.  Just experiment constantly until you find your own
personal happy-medium.  Everybody's conversion techniques are highly
specific to the application.  Mine was based on a YouTube benchmark, and
having no control over the type or size of input video.



More information about the MEncoder-users mailing list