[FFmpeg-trac] #9201(undetermined:reopened): -c:v mpeg2video ignoring -qmin+qmax
FFmpeg
trac at avcodec.org
Tue Apr 27 04:46:53 EEST 2021
#9201: -c:v mpeg2video ignoring -qmin+qmax
-------------------------------------+-------------------------------------
Reporter: Warren | Owner: (none)
Young |
Type: defect | Status: reopened
Priority: normal | Component:
| undetermined
Version: unspecified | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Changes (by Warren Young):
* status: closed => reopened
* resolution: needs_more_info =>
Comment:
> you can either set a bitrate or use a constant quantizer
I've got bitrate graphs that say different. Not only does combining
`-q/qmin/qmax` with `-maxrate` clip the bit rate as requested — to a point
— ffmpeg doesn't refuse to encode when you combine these options.
(These graphs were produced by [https://github.com/wyoung/etr-bv an R
script I wrote that wraps ffprobe].)
> complete, uncut console output
Here it is, boiled down to the smallest command I can come up with that
shows the symptom:
{{{
$ ffmpeg -i 5233t.mp4 -c:v mpeg2video -c:a copy -qmax 10 -maxrate 18M -y
5233t.ts
ffmpeg version N-102053-g2a623bacc8 Copyright (c) 2000-2021 the FFmpeg
developers
built with gcc 8 (GCC)
configuration: --enable-libvpx --enable-libx264 --enable-gpl
libavutil 56. 74.100 / 56. 74.100
libavcodec 58.137.100 / 58.137.100
libavformat 58. 79.100 / 58. 79.100
libavdevice 58. 14.100 / 58. 14.100
libavfilter 7.111.100 / 7.111.100
libswscale 5. 10.100 / 5. 10.100
libswresample 3. 10.100 / 3. 10.100
libpostproc 55. 10.100 / 55. 10.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '5233t.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: isommp41mp42
creation_time : 2021-04-27T01:07:37.000000Z
Duration: 00:00:15.30, start: 0.000000, bitrate: 19516 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1920x1080 [SAR 1:1 DAR 16:9], 17072 kb/s, 28.38 fps, 29.97 tbr,
30k tbn, 60k tbc (default)
Metadata:
creation_time : 2021-04-27T01:07:37.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 317 kb/s (default)
Metadata:
creation_time : 2021-04-27T01:07:37.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpeg2video @ 0x2efbdc0] Automatically choosing VBV buffer size of 268
kbyte
Output #0, mpegts, to '5233t.ts':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: isommp41mp42
encoder : Lavf58.79.100
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, bt709,
progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.97 fps,
90k tbn (default)
Metadata:
creation_time : 2021-04-27T01:07:37.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : Lavc58.137.100 mpeg2video
Side data:
cpb: bitrate max/min/avg: 18000000/0/200000 buffer size: 2195456
vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 317 kb/s (default)
Metadata:
creation_time : 2021-04-27T01:07:37.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
[mpeg2video @ 0x2efbdc0] rc buffer underflowime=00:00:05.14
bitrate=13052.9kbits/s speed=4.58x
[mpeg2video @ 0x2efbdc0] max bitrate possibly too small or try trellis
with large lmax or increase qmax
[mpeg2video @ 0x2efbdc0] rc buffer underflowime=00:00:06.99
bitrate=14685.7kbits/s speed=4.28x
[mpeg2video @ 0x2efbdc0] max bitrate possibly too small or try trellis
with large lmax or increase qmax
[mpeg2video @ 0x2efbdc0] rc buffer underflow
[mpeg2video @ 0x2efbdc0] max bitrate possibly too small or try trellis
with large lmax or increase qmax
[mpeg2video @ 0x2efbdc0] rc buffer underflow
[mpeg2video @ 0x2efbdc0] max bitrate possibly too small or try trellis
with large lmax or increase qmax
[mpeg2video @ 0x2efbdc0] rc buffer underflowime=00:00:08.66
bitrate=15496.2kbits/s speed=4.05x
[mpeg2video @ 0x2efbdc0] max bitrate possibly too small or try trellis
with large lmax or increase qmax
frame= 459 fps=127 q=31.0 Lsize= 23842kB time=00:00:15.31
bitrate=12751.1kbits/s speed=4.24x
video:22621kB audio:593kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 2.702119%
}}}
Points of interest:
1. It is showing `q=31.0` despite `-qmax 10`. If you add `-vstats` to the
command, you will find that the `q=` value ramps quickly up to 31.0 and
stays there most of the time, flickering down to 24.8, as reported above.
2. It is not the case that `-qmax` is being ignored, however. This may
simply be a display bug, because changing `-qmax` to 11 in the above
command allows it to succeed.
> an input sample if the issue is not reproducible with testsrc2.
That's a bad test source for this sort of problem, since `testsrc2`
generates a nearly-CBR stream. You need something with some bitrate
variability to give `-maxrate` something to clip.
Since I couldn't find an official ffmpeg test source with such
variability, I've snipped a 15-second section from the particular video I
ran into this with,
[https://drive.google.com/file/d/1aLQJKDoTl7Knnvn15-B_jni2fJpC2aV2/view?usp=sharing
here]. (This is the `5233t.mp4` file referenced in the quoted command
output above.)
I still believe you could have experienced the same problem with a large
number of other videos. All you need is something sufficiently VBR, then
set the bitrate control parameters tight enough that the symptom occurs.
If you point me at a suitably-VBR file you trust for testing such things,
I'm sure I can make ffmpeg squeal with it, too.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9201#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list