[FFmpeg-trac] #880(avcodec:new): bad two first frames when mpeg2video encoding

FFmpeg trac at avcodec.org
Fri Jan 6 12:25:58 CET 2012


#880: bad two first frames when mpeg2video encoding
-------------------------------------+-------------------------------------
             Reporter:  kuzyag       |                    Owner:
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:  avcodec
              Version:  unspecified  |               Resolution:
             Keywords:  bad 2 first  |               Blocked By:
  frames, mpeg2video                 |  Reproduced by developer:  0
             Blocking:               |
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------

Comment (by kuzyag):

 using bisection against git i found a commit that broke "my picture"

 last good commit:
 http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=3009f521f390b2bd440d9747a9c6baf648b2087a

 first bad commit:
 http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=bf174a70cde333eba7e27063f9ce44497108f466

 we used a script for test
 {{{
 ./ffmpeg \
 -i $1 \
 -an \
 -vcodec mpeg2video \
 -r 25 \
 -mbd rd \
 -vb 40000k -maxrate 40000k -minrate 40000k -bufsize 20000k \
 -flags +ilme+ildct \
 -vframes 15 \
 -f rawvideo \
 -y $2
 }}}

 output that has a good first picture:
 {{{
 [...]
 Output #0, rawvideo, to
 '/var/www/users/storyparts/spool/restored/test.mpg':
   Metadata:
     creation_time   : 2011-12-13 12:49:34
     encoder         : Lavf53.2.0
     Stream #0.0(eng): Video: mpeg2video (hq), yuv422p, 1440x1080 [PAR 4:3
 DAR 16:9], q=2-31, 40000 kb/s, 90k tbn, 25 tbc
     Metadata:
       creation_time   : 2011-12-13 12:50:10
 Stream mapping:
   Stream #0.0 -> #0.0
 Press ctrl-c to stop encoding
 frame=    4 fps=  0 q=2.0 size=     916kB time=0.12 bitrate=62518.3kbits/s
 frame=    8 fps=  7 q=3.3 size=    1702kB time=0.28 bitrate=49788.4kbits/s
 frame=   12 fps=  6 q=2.1 size=    2489kB time=0.44 bitrate=46340.7kbits/s
 frame=   15 fps=  7 q=3.0 Lsize=    3003kB time=0.56
 bitrate=43936.6kbits/s
 video:3003kB audio:0kB global headers:0kB muxing overhead 0.000000%
 [...]
 }}}

 output that has a bad first picture:
 {{{
 Output #0, rawvideo, to
 '/var/www/users/storyparts/spool/restored/test.mpg':
   Metadata:
     creation_time   : 2011-12-13 12:49:34
     encoder         : Lavf53.2.0
     Stream #0.0(eng): Video: mpeg2video (hq), yuv422p, 1440x1080 [PAR 4:3
 DAR 16:9], q=2-31, 40000 kb/s, 90k tbn, 25 tbc
     Metadata:
       creation_time   : 2011-12-13 12:50:10
 Stream mapping:
   Stream #0.0 -> #0.0
 Press ctrl-c to stop encoding
 [mpeg2video @ 0x9eb40c0] rc buffer underflow
 frame=    3 fps=  0 q=4.3 size=     148kB time=0.08 bitrate=15137.7kbits/s
 frame=    5 fps=  4 q=3.0 size=     428kB time=0.16 bitrate=21898.0kbits/s
 frame=    7 fps=  4 q=3.0 size=     704kB time=0.24 bitrate=24029.6kbits/s
 frame=    9 fps=  4 q=3.0 size=     979kB time=0.32 bitrate=25055.1kbits/s
 frame=   12 fps=  4 q=2.0 size=    1627kB time=0.44 bitrate=30294.7kbits/s
 frame=   15 fps=  4 q=2.0 size=    2259kB time=0.56 bitrate=33045.1kbits/s
 frame=   15 fps=  4 q=2.0 Lsize=    2259kB time=0.56
 bitrate=33045.1kbits/s
 video:2259kB audio:0kB global headers:0kB muxing overhead 0.000000%
 }}}

 the difference to me is quality parameter of first frames. for good
 pictures is has value q=2.0 but for bad it has value q=4.3

 the cure is to specify ffmpeg's option -qmax 2.0 or -qmax 3.0

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/880#comment:3>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list