[Ffmpeg-devel] MPEG 2 Quality Issues

Brian Brice bbrice
Fri Dec 1 19:30:12 CET 2006


Baptiste Coudurier wrote:
> Hi
> 
> Brian Brice wrote:
>> Hello.
>>
>> A while back I had emailed about bitrate issues regarding MPEG 2
>> encoding, and now I'm back for quality issues!  I have a DV clip
>> that contains some fast motion and I'm getting some horrible blocking
>> when trying to encode to MPEG 2.  I am trying to find the right options
>> to pass to ffmpeg that make a huge different in the quality of the
>> encoding.  I've used TMPGEnc and it produced *great* results, and I wish
>> I could get ffmpeg up to the same standard.  At this point I'm just
>> passing numbers without knowing what they do.
>>
>> I have tried setting lmin to 0 and lmax to 1*QP2LAMBDA.  This video
>> smooth like I would expect, but the bitrate ended up averaging around
>> 13.7 Mbps even though I tried to aim for CBR 7 Mbps.
>>
>> Here's a sample screenshot of how TMPGEnc looks to ffmpeg:
>> TMPGEnc: http://heapify.org/etc/ffm/tmpgenc.png
>> ffmpeg:  http://heapify.org/etc/ffm/ffmpeg.png
>> Major blocky-ness with ffmpeg :-(
>>
>> Here is the original clip:
>> http://heapify.org/etc/ffm/TestforMPG-Short.avi
>>
>> Encoded with ffmpeg without lmin/lmax settings:
>> http://heapify.org/etc/ffm/YuckNolminlmax.mpg
>>
>> Encoded with TMPGEnc, looks *great* as I want ffmpeg's to :-(
>> http://heapify.org/etc/ffm/TMPGEnc.mpg
>>
>> Here is how I used ffmpeg:
>> ffmpeg -i TestforMPG-Short.avi -y -f vob -vcodec mpeg2video -acodec mp2
>> -ab 384k -ar 48000 -ac 2 -aspect 4:3 -b 7000k -minrate 7000k -maxrate
>> 7000k -bufsize 1835008 -g 12 -bf 2 -flags ildct+trell -mbd 2
>> LooksGoodBadBitrate.mpg
>>
>> I know ffmpeg is capable of having decent quality at 7 Mbps, but how can
>> I achieve this?  TMPGEnc does it, how can ffmpeg?  Any advice,
>> recommendations, information is greatly needed and appreciated.  Thank
>> you guys.
>>
> 
> ffmpeg -i TestforMPG-Short.avi -vcodec mpeg2video -minrate 7000k
> -maxrate 7000k -b 7000k -bufsize 5000k -bf 2 -flags +qprd+ildct -flags2
> +ivlc+sgop -mbd rd -sc_threshold 10000000 -lmin 1 -mblmin 1 -lmax
> '340*QP2LAMBDA' -f vob -ab 192 ffmpeg.mpg

Some of these improve the quality slightly.  There's still major
noticable blocking.  I stuck the bufsize to 224KiB because that's
standard (I think?) for DVD.  Increasing that size makes the video look
a lot better, but of course hardware devices won't take it.

> Feel free to add +trell.
> 
> You must know that every encoder around WILL activate qprd. You can
> detect it by using -debug 16, if macroblocks have differents values then
> qprd is activated.

I've tried having -flags +qprd, but it seems that ffmpeg always froze
before even printing out the first frame information.  I figured it must
be doing some processing, so I left it alone.  Two hours later, it
hadn't moved.  What happened there?

> 
> Always try to use the largest bufsize for rc, the bigger buffer is, the
> more rc will be efficient.
> 


-- 
Brian Brice




More information about the ffmpeg-devel mailing list