[FFmpeg-trac] #8297(ffmpeg:new): MPEG-TS with -muxrate gets confused by a start pts not 0

FFmpeg trac at avcodec.org
Thu Oct 17 11:05:09 EEST 2019


#8297: MPEG-TS with -muxrate gets confused by a start pts not 0
-------------------------------------+-------------------------------------
             Reporter:  rossixolit   |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  ffmpeg       |                  Version:  4.2
             Keywords:  mpeg-ts,     |               Blocked By:
  muxrate, pts, copyts               |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 When combining -muxrate with -output_ts_offset >0 or -copyts (when the
 copied start ts > 0) the muxer takes that time from 0 to start ts into
 account and creates huge outputs (muxing overhead / bitrate grows with
 start ts).

 Here are two outputs, first with 0 output_ts_offset, then with 200. The
 first one comes pretty close to the requested muxrate of 300k with 301.4k,
 the second one has 3318.3k.

 How to reproduce:
 {{{
 % ffmpeg -f lavfi -i testsrc -t 20 -output_ts_offset 0 -f mpegts -muxrate
 300000 -c:v libx264 -y /dev/null
 ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
   built with Apple clang version 11.0.0 (clang-1100.0.33.8)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
 --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-
 cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
 -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
 -fno-stack-check' --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-libvidstab --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-libsoxr
 --enable-videotoolbox --disable-libjack --disable-indev=jack
   libavutil      56. 31.100 / 56. 31.100
   libavcodec     58. 54.100 / 58. 54.100
   libavformat    58. 29.100 / 58. 29.100
   libavdevice    58.  8.100 / 58.  8.100
   libavfilter     7. 57.100 /  7. 57.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  5.100 /  5.  5.100
   libswresample   3.  5.100 /  3.  5.100
   libpostproc    55.  5.100 / 55.  5.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
 Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
 Press [q] to stop, [?] for help
 [libx264 @ 0x7fe406010800] using SAR=1/1
 [libx264 @ 0x7fe406010800] using cpu capabilities: MMX2 SSE2Fast SSSE3
 SSE4.2 AVX FMA3 BMI2 AVX2
 [libx264 @ 0x7fe406010800] profile High 4:4:4 Predictive, level 1.3, 4:4:4
 8-bit
 Output #0, mpegts, to '/dev/null':
   Metadata:
     encoder         : Lavf58.29.100
     Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR
 4:3], q=-1--1, 25 fps, 90k tbn, 25 tbc
     Metadata:
       encoder         : Lavc58.54.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
 frame=  500 fps=0.0 q=-1.0 Lsize=     731kB time=00:00:19.88 bitrate=
 301.4kbits/s speed=56.4x
 video:83kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 776.126770%
 [libx264 @ 0x7fe406010800] frame I:2     Avg QP:15.01  size:  3525
 [libx264 @ 0x7fe406010800] frame P:135   Avg QP:13.52  size:   455
 [libx264 @ 0x7fe406010800] frame B:363   Avg QP:13.87  size:    47
 [libx264 @ 0x7fe406010800] consecutive B-frames:  1.0%  0.0% 19.8% 79.2%
 [libx264 @ 0x7fe406010800] mb I  I16..4: 71.2%  0.0% 28.8%
 [libx264 @ 0x7fe406010800] mb P  I16..4:  3.2%  0.0%  0.8%  P16..4:  7.3%
 3.8%  2.6%  0.0%  0.0%    skip:82.3%
 [libx264 @ 0x7fe406010800] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  4.0%
 0.1%  0.0%  direct: 0.1%  skip:95.7%  L0:53.9% L1:41.7% BI: 4.3%
 [libx264 @ 0x7fe406010800] coded y,u,v intra: 9.9% 10.2% 8.9% inter: 0.7%
 0.7% 0.6%
 [libx264 @ 0x7fe406010800] i16 v,h,dc,p: 62% 22%  2% 14%
 [libx264 @ 0x7fe406010800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 56% 12%  1%
 1%  1%  0%  1%  0%
 [libx264 @ 0x7fe406010800] Weighted P-Frames: Y:0.0% UV:0.0%
 [libx264 @ 0x7fe406010800] ref P L0: 69.4%  6.0% 20.9%  3.7%
 [libx264 @ 0x7fe406010800] ref B L0: 55.2% 41.9%  2.9%
 [libx264 @ 0x7fe406010800] ref B L1: 97.6%  2.4%
 [libx264 @ 0x7fe406010800] kb/s:34.20
 }}}


 {{{
 % ffmpeg -f lavfi -i testsrc -t 20 -output_ts_offset 200 -f mpegts
 -muxrate 300000 -c:v libx264 -y /dev/null
 ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
   built with Apple clang version 11.0.0 (clang-1100.0.33.8)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
 --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-
 cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
 -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
 -fno-stack-check' --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-libvidstab --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-libsoxr
 --enable-videotoolbox --disable-libjack --disable-indev=jack
   libavutil      56. 31.100 / 56. 31.100
   libavcodec     58. 54.100 / 58. 54.100
   libavformat    58. 29.100 / 58. 29.100
   libavdevice    58.  8.100 / 58.  8.100
   libavfilter     7. 57.100 /  7. 57.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  5.100 /  5.  5.100
   libswresample   3.  5.100 /  3.  5.100
   libpostproc    55.  5.100 / 55.  5.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
 Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
 Press [q] to stop, [?] for help
 [libx264 @ 0x7f8885806e00] using SAR=1/1
 [libx264 @ 0x7f8885806e00] using cpu capabilities: MMX2 SSE2Fast SSSE3
 SSE4.2 AVX FMA3 BMI2 AVX2
 [libx264 @ 0x7f8885806e00] profile High 4:4:4 Predictive, level 1.3, 4:4:4
 8-bit
 Output #0, mpegts, to '/dev/null':
   Metadata:
     encoder         : Lavf58.29.100
     Stream #0:0: Video: h264 (libx264), yuv444p, 320x240 [SAR 1:1 DAR
 4:3], q=-1--1, 25 fps, 90k tbn, 25 tbc
     Metadata:
       encoder         : Lavc58.54.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
 frame=  500 fps=0.0 q=-1.0 Lsize=    8053kB time=00:00:19.88
 bitrate=3318.3kbits/s speed=  58x
 video:83kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 9545.531250%
 [libx264 @ 0x7f8885806e00] frame I:2     Avg QP:15.01  size:  3525
 [libx264 @ 0x7f8885806e00] frame P:135   Avg QP:13.52  size:   455
 [libx264 @ 0x7f8885806e00] frame B:363   Avg QP:13.87  size:    47
 [libx264 @ 0x7f8885806e00] consecutive B-frames:  1.0%  0.0% 19.8% 79.2%
 [libx264 @ 0x7f8885806e00] mb I  I16..4: 71.2%  0.0% 28.8%
 [libx264 @ 0x7f8885806e00] mb P  I16..4:  3.2%  0.0%  0.8%  P16..4:  7.3%
 3.8%  2.6%  0.0%  0.0%    skip:82.3%
 [libx264 @ 0x7f8885806e00] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  4.0%
 0.1%  0.0%  direct: 0.1%  skip:95.7%  L0:53.9% L1:41.7% BI: 4.3%
 [libx264 @ 0x7f8885806e00] coded y,u,v intra: 9.9% 10.2% 8.9% inter: 0.7%
 0.7% 0.6%
 [libx264 @ 0x7f8885806e00] i16 v,h,dc,p: 62% 22%  2% 14%
 [libx264 @ 0x7f8885806e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 56% 12%  1%
 1%  1%  0%  1%  0%
 [libx264 @ 0x7f8885806e00] Weighted P-Frames: Y:0.0% UV:0.0%
 [libx264 @ 0x7f8885806e00] ref P L0: 69.4%  6.0% 20.9%  3.7%
 [libx264 @ 0x7f8885806e00] ref B L0: 55.2% 41.9%  2.9%
 [libx264 @ 0x7f8885806e00] ref B L1: 97.6%  2.4%
 [libx264 @ 0x7f8885806e00] kb/s:34.20
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8297>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list