#1175: mpeg2 (PS) writes bad bitrate/muxrate -------------------------------------+------------------------------------- Reporter: tracey_pooh | Type: defect Status: new | Priority: critical Component: avformat | Version: git- Keywords: mpeg2 | master header bug | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- example way to show the bug:
/tmp/f/ffmpeg/ffmpeg -y -i ANYVIDEO -target ntsc-dvd -frames 1 xxx.mpg; hexdump -C -s10 -n3 xxx.mpg; buggy: 0000000a 0c 4e 03 should be (was prior to nov2011): 0000000a 01 89 c3 the correct value, which is the 22 bits of the 3 bytes above, * 400 (gdb) p (0x0189c3 >> 2) * 400 $17 = 10080000 is the value that the "-muxrate" ffmpeg param defaults to unless overridden and is what "-target ntsc-dvd" will also set to. so the ffmpeg param translating into the internal storage of mpegenc.c is off by 400. You can see the bug a little more obviously because the "put_bits()" of 22 bits int value in current state is 24 bits 8-) a sample fix/patch: diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 0df0149..1e9e2ed 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -423,7 +423,10 @@ static int mpeg_mux_init(AVFormatContext *ctx) video_bitrate += codec_rate; } - if (!s->mux_rate) { + if (s->mux_rate) { + s->mux_rate /= 400; // internal param is in units of 50 bytes + } + else { /* we increase slightly the bitrate to take into account the headers. XXX: compute it exactly */ bitrate += bitrate / 20; -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/1175> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker _______________________________________________ FFmpeg-trac mailing list FFmpeg-trac@avcodec.org http://avcodec.org/mailman/listinfo/ffmpeg-trac