Opened 12 years ago

Closed 12 years ago

#880 closed defect (fixed)

bad two first frames when mpeg2video encoding

Reported by: kuzyag Owned by:
Priority: normal Component: avcodec
Version: unspecified Keywords: bad 2 first frames, mpeg2video
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

When I encode using <b>mpeg2video</b>, in resulting video I have first two frames in very low quality.

D:\tmp\9>ffmpeg.exe -threads 8 -i c1_1_13.12.11.mov -vcodec mpeg2video -vb 40000k -maxrate 40000k -minrate 40000k -bufsize 20000k -threads 8 -y test_encoding.mpg
ffmpeg version N-36363-g0af34c4, Copyright (c) 2000-2012 the FFmpeg developers
  built on Jan  3 2012 02:35:39 with gcc 4.5.0 20100414 (Fedora MinGW 4.5.0-1.fc14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-mingw32-gcc' --enable-w
32threads --enable-memalign-hack --enable-runtime-cpudetect --enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -lwinmm' --extra-cflags='--static -I/var/
www/users/research/ffmpeg/snapshots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/snapshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable
-version3 --enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-libopencor
e-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      51. 33.100 / 51. 33.100
  libavcodec     53. 50.100 / 53. 50.100
  libavformat    53. 29.100 / 53. 29.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 57.101 /  2. 57.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  5.100 /  0.  5.100
  libpostproc    51.  2.100 / 51.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c1_1_13.12.11.mov':
  Metadata:
    creation_time   : 2011-12-13 12:49:19
  Duration: 00:01:02.40, start: 0.000000, bitrate: 120761 kb/s
    Stream #0:0(eng): Video: dvvideo (dvh5 / 0x35687664), yuv422p, 1440x1080 [SAR 4:3 DAR 16:9], 115200 kb/s, 25 fps, 25 tbr, 2500 tbn, 25 tbc
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:2(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:3(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:4(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:5(eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
[buffer @ 0x18af460] w:1440 h:1080 pixfmt:yuv422p tb:1/1000000 sar:4/3 sws_param:
Output #0, mpeg, to 'test_encoding.mpg':
  Metadata:
    creation_time   : 2011-12-13 12:49:19
    encoder         : Lavf53.29.100
    Stream #0:0(eng): Video: mpeg2video, yuv422p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 40000 kb/s, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
    Stream #0:1(eng): Audio: mp2, 48000 Hz, 1 channels, s16, 128 kb/s
    Metadata:
      creation_time   : 2011-12-13 12:50:22
      handler_name    : ?Apple Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (dvvideo -> mpeg2video)
  Stream #0:1 -> #0:1 (pcm_s16le -> mp2)
Press [q] to stop, [?] for help
[mpeg2video @ 0x18afb40] rc buffer underflow
frame= 1560 fps=  4 q=3.0 Lsize=  305932kB time=00:01:02.36 bitrate=40189.1kbits/s
video:303882kB audio:975kB global headers:0kB muxing overhead 0.352519%

Attachments (3)

1-st_frame.jpg (208.6 KB ) - added by kuzyag 12 years ago.
1-st frame in resulting video
2-nd_frame.jpg (431.0 KB ) - added by kuzyag 12 years ago.
2-nd frame in resulting video
3-rd_frame.jpg (867.2 KB ) - added by kuzyag 12 years ago.
3-rd frame in resulting video

Download all attachments as: .zip

Change History (7)

by kuzyag, 12 years ago

Attachment: 1-st_frame.jpg added

1-st frame in resulting video

by kuzyag, 12 years ago

Attachment: 2-nd_frame.jpg added

2-nd frame in resulting video

by kuzyag, 12 years ago

Attachment: 3-rd_frame.jpg added

3-rd frame in resulting video

comment:1 by Carl Eugen Hoyos, 12 years ago

Is your problem related to -threads 8?
Is it also reproducible with -threads 1?

in reply to:  1 comment:2 by kuzyag, 12 years ago

Replying to cehoyos:

Is your problem related to -threads 8?
Is it also reproducible with -threads 1?

Yes.

comment:3 by kuzyag, 12 years ago

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

comment:4 by Michael Niedermayer, 12 years ago

Reproduced by developer: set
Resolution: fixed
Status: newclosed

fix sent to ML, will be in git soon

Note: See TracTickets for help on using tickets.