Opened 11 years ago
Closed 10 years ago
#3091 closed defect (needs_more_info)
High Bitrate I-frame CBR MPEG encoding causes error
Reported by: | Michael Orton | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | mpeg2video |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
m2v encoding of I-frame CBR mpeg at 100Mbit/sec and above gives bitrate tolerance too small for bitrate error. Below 100Mbit, error does not arise.
reproduced with XDcam demuxed m2v file:
ffmpeg.exe -i c:\tmpdir\work.m2v -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -minrate 150M -maxrate 150M -bufsize 47185920 -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Sep 26 2013 01:50:16 with gcc 4.8.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegvideo, from 'c:\tmpdir\work.m2v':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mpeg2video @ 02793a60] bitrate tolerance too small for bitrate
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 150000 kb/s, 90k tbn, 25 tbc
Stream mapping:
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Have source file if needed.
TIA
Change History (13)
comment:1 by , 11 years ago
Component: | FFmpeg → undetermined |
---|
comment:2 by , 11 years ago
Yes reproducible:
f86387bffmpeg.exe -f lavfi -i testsrc -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -minrate 150M -maxrate 150M -bufsize 47185920 -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version N-57605-gf86387b Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 18:01:53 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, lavfi, from 'testsrc':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[mpeg2video @ 027ae1a0] bitrate tolerance too small for bitrate
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Stream #0:0: Video: mpeg2video, yuv422p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 150000 kb/s, 90k tbn, 25 tbc
Stream mapping:
comment:3 by , 11 years ago
The documentations states that the default for -bt
is 4M (and that a too small value is bad for quality). For some (sufficiently large) bitrate, the default must be too small to even encode. FFmpeg is warning that you have to increase the value. I wonder what could be changed.
$ ffmpeg -f lavfi -i testsrc=s=1920x1080 -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -minrate 150M -maxrate 150M -bufsize 47185920 -r 25 -f null - ffmpeg version N-57552-g0e85bfe Copyright (c) 2000-2013 the FFmpeg developers built on Oct 30 2013 00:35:19 with gcc 4.7 (SUSE Linux) configuration: --enable-gpl libavutil 52. 48.100 / 52. 48.100 libavcodec 55. 39.100 / 55. 39.100 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, lavfi, from 'testsrc=s=1920x1080': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc [mpeg2video @ 0x1bbabe0] bitrate tolerance too small for bitrate Output #0, null, to 'pipe:': Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 150000 kb/s, 90k tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> mpeg2video) Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
follow-up: 5 comment:4 by , 11 years ago
The difficulty with adding a -bt flag (10M seems to work) is that the stream is then marked as VBR instead of CBR, and the encoded frames are no longer the expected constant size. The actual encoded size I worked out to be max about 100Mbit/sec. The aim is to achieve a CBR I frame encoding similar to IMX.
I guess if the -bt default were to scale with bitrate, that would make sense, as then the resulting bitstream would be constant frame size and marked as CBR(?)
comment:5 by , 11 years ago
Replying to ortoni:
The difficulty with adding a -bt flag (10M seems to work) is that the stream is then marked as VBR instead of CBR,
How can I reproduce this?
and the encoded frames are no longer the expected constant size.
While CBR != constant frame size, I see constant frame size for -b:v 150M -minrate 150M -bt 6M
, please elaborate.
follow-up: 7 comment:6 by , 11 years ago
I could not get -b:v 150M -minrate 150M -bt 6M to work - still had "bitrate tolerance too small.." [maxrate and bufsize removed]
Increasing -bt: -b:v 150M -minrate 150M -bt 8M was allowed but m2v sequence header says BR = 104,857,200, with sequence length (i.e. # bits/frame) variable, vbv bufsize was 15,138,816. Mediainfo calculated the bitrate as 45.6Mbps.
Adding -maxrate and bufsize: -b:v 150M -minrate 150M -maxrate 150M -bt 8M -bufsize 47185920, m2v seq HDR now says BR=45,142,400, sequence length is constant, vbv bufsize is 13,631,488 and Mediainfo says "overall bitrate 149Mb/s" but Maximum Bitrate is 46.8Mbps
All tests on same git as original; and I'm very confused!
comment:7 by , 11 years ago
Replying to ortoni:
I could not get -b:v 150M -minrate 150M -bt 6M to work - still had "bitrate tolerance too small.." [maxrate and bufsize removed]
Command line and complete, uncut console output missing.
comment:8 by , 11 years ago
my bad:
f86387bffmpeg.exe -i c:\tmpdir\work.m2v -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -minrate 150M -bt 6M -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version N-57605-gf86387b Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 18:01:53 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegvideo, from 'c:\tmpdir\work.m2v':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], max. 50000 kb/s, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mpeg2video @ 02528b40] Warning min_rate > 0 but min_rate != max_rate isn't recommended!
[mpeg2video @ 02528b40] bitrate tolerance too small for bitrate
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 150000 kb/s,
90k tbn, 25 tbc
Stream mapping:
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
comment:9 by , 11 years ago
Is there any other information I can investigate and report for this ticket @cehoyos?
Thanks and regards
comment:11 by , 11 years ago
Sorry was following your exact CLI above - thought that was odd. Correct output below, seems unchanged :
f86387bffmpeg.exe" -i c:\tmpdir\work.m2v -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -maxrate 150M -minrate 150M -bt 6M -bufsize 47185920 -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version N-57605-gf86387b Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 18:01:53 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegvideo, from 'c:\tmpdir\work.m2v':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], max. 50000 kb/s, 25 fps, 25 tbr, 1200k tbn, 50 tbc
[mpeg2video @ 02618b20] bitrate tolerance too small for bitrate
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 150000 kb/s,
90k tbn, 25 tbc
Stream mapping:
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Using -bt 8M proceeds:
f86387bffmpeg.exe" -i c:\tmpdir\work.m2v -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 150M -maxrate 150M -minrate 150M -bt 8M -bufsize 47185920 -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version N-57605-gf86387b Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 18:01:53 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegvideo, from 'c:\tmpdir\work.m2v':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], max. 50000 kb/s, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 150000 kb/s,90k tbn, 25 tbc
Stream mapping:
Press [q] to stop, ? for help
frame= 500 fps= 58 q=1.6 Lsize= 364771kB time=00:00:19.96 bitrate=149709.6kbits/s
video:364771kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.000000%
but this encoding above shows in MediaInfo:
Bit rate : 149 Mbps
Maximum bit rate : 46.8 Mbps
and my m2v essence tool shows at bitrate of 45,142,400 and VBV size= 13,631,488 in the Sequence header
But 99M is happy:
f86387bffmpeg.exe" -i c:\tmpdir\work.m2v -vcodec mpeg2video -pix_fmt yuv422p -intra -flags +ildct+ilme -b:v 99M -maxrate 99M -minrate 99M -bt 6M -bufsize 47185920 -r 25 -an -y c:\tmpdir\xdcam.m2v
ffmpeg version N-57605-gf86387b Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 29 2013 18:01:53 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegvideo, from 'c:\tmpdir\work.m2v':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], max. 50000 kb/s, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, mpeg2video, to 'c:\tmpdir\xdcam.m2v':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: mpeg2video, yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 99000 kb/s, 90k tbn, 25 tbc
And for this one MediaInfo reports:
Overall bit rate : 98.4 Mbps
Bit rate : 99.0 Mbps
m2v sequence header bitrate = 99,000,000 and vbv = 13,631,488
Its just anything over 100Mbps seems not to encode correctly
comment:12 by , 11 years ago
CBR is not the same as constant frame sizes.
Which do you want ? and why ?
and i wouldnt trust mediainfo when it comes to CBR bitrates
comment:13 by , 10 years ago
Keywords: | mpeg2video added |
---|---|
Resolution: | → needs_more_info |
Status: | new → closed |
Please reopen this ticket if you can answer Michael's questions.
Is this problem reproducible when using
-f lavfi -i testsrc
as input?Please test current git head and report back.