[FFmpeg-trac] #8048(avformat:new): MPEG-2 muxer overshoots and corrects with undershoot in CBR mode (-muxrate)

FFmpeg trac at avcodec.org
Tue Jul 30 05:32:07 EEST 2019


#8048: MPEG-2 muxer overshoots and corrects with undershoot in CBR mode (-muxrate)
------------------------------------+------------------------------------
             Reporter:  tangent     |                    Owner:
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  avformat
              Version:  git-master  |               Resolution:
             Keywords:  mpegts      |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+------------------------------------

Comment (by tangent):

 Please provide a working command line

 The above command line was constructed from memory, so yes, it fails, but
 all you have to do to fix is is swap the order of the -i and -f options.
 The fixed version is below.

 ----

     complete, uncut console output

 {{{
 $ ffmpeg -i input.mp4 -f mpegts -c copy -muxrate 13.5M -y
 ~/Desktop/output.ts
 ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
   built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.4_1 --enable-shared
 --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-
 cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include
 -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin'
 --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-
 libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-
 librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora
 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype
 --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-
 libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex
 --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-
 libaom --enable-libsoxr
   libavutil      56. 22.100 / 56. 22.100
   libavcodec     58. 35.100 / 58. 35.100
   libavformat    58. 20.100 / 58. 20.100
   libavdevice    58.  5.100 / 58.  5.100
   libavfilter     7. 40.101 /  7. 40.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  3.100 /  5.  3.100
   libswresample   3.  3.100 /  3.  3.100
   libpostproc    55.  3.100 / 55.  3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
   Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: mp41isom
     creation_time   : 2019-07-28T20:14:36.000000Z
   Duration: 00:01:26.63, start: 0.000000, bitrate: 2383 kb/s
     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 /
 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 2382 kb/s, 30.30 fps,
 30.30 tbr, 30k tbn, 60 tbc (default)
     Metadata:
       creation_time   : 2019-07-28T20:14:36.000000Z
       handler_name    : VideoHandler
       encoder         : AVC Coding
 Output #0, mpegts, to '/Users/tangent/Desktop/output.ts':
   Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: mp41isom
     encoder         : Lavf58.20.100
     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 /
 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2382 kb/s,
 30.30 fps, 30.30 tbr, 90k tbn, 30k tbc (default)
     Metadata:
       creation_time   : 2019-07-28T20:14:36.000000Z
       handler_name    : VideoHandler
       encoder         : AVC Coding
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 [mpegts @ 0x7ff4d6800000] dts < pcr, TS is invalid:00:21.94
 bitrate=13474.5kbits/s speed=40.5x
     Last message repeated 31 times
 [mpegts @ 0x7ff4d6800000] dts < pcr, TS is invalid:00:34.88
 bitrate=13587.8kbits/s speed=  32x
     Last message repeated 34 times
 [mpegts @ 0x7ff4d6800000] dts < pcr, TS is invalid:00:43.23
 bitrate=13486.2kbits/s speed=26.7x
     Last message repeated 16 times
 frame= 2625 fps=826 q=-1.0 Lsize=  142700kB time=00:01:26.59
 bitrate=13500.0kbits/s speed=27.3x
 video:25198kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 466.314453%
 }}}

 This machine doesn't have the git-master build on it, so I'm using the
 latest stable release version instead, but as I wrote above, it's been
 happening for probably years now, so I don't believe we need to be too
 picky about which version we test with.

 ----

     explain how you tested the actual muxing rate.

 That's explained above: with etr-bv, an open source tool I wrote for the
 purpose and put on GitHub. It is a wrapper around ffprobe -show_frames
 output. Based on the reported pkt_pos values, I can get bits per frame,
 from which I can produce the bar charts I linked you to.

 etr-bv runs using widely-available open source tools, so you can replicate
 the symptom there.

 If you have a preferred bit rate graphing tool, I expect I can show the
 same symptom using it instead.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8048#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list