[FFmpeg-trac] #8448(ffmpeg:new): timestamp issue muxing raw .264 into .mkv/.m2ts

FFmpeg trac at avcodec.org
Sun Dec 29 12:43:30 EET 2019


#8448: timestamp issue muxing raw .264 into .mkv/.m2ts
-------------------------------------+-------------------------------------
             Reporter:  Selur        |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  ffmpeg       |                  Version:
                                     |  unspecified
             Keywords:  raw 264 mux  |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 Muxing raw H264 content to mkv fails.

 How to reproduce:
 1. Use Sample_7Ch-001.mkv
 (https://drive.google.com/open?id=17GvV7mOGPaLMaOmJuyZv7AfhRsdrBM-D)
 and
 {{{
 ffmpeg -y -i "C:\Users\Selur\Desktop\Sample_7Ch-001.mkv" -map 0:0 -vcodec
 copy -an -sn  -map_metadata -1 -bsf:v
 h264_mp4toannexb,filter_units=remove_types=6 "E:\Output\Sample_7Ch-
 001_11_35_02_4510_01.264"
 }}}
 to extract the raw video stream.
 This works fine:
 {{{
 ffmpeg version N-95921-g8067c0c2eb-ge5db2e96c0+3 Copyright (c) 2000-2019
 the FFmpeg developers
   built with gcc 9.2.0 (Rev2, Built by MSYS2 project)
   configuration:  --disable-autodetect --enable-amf --enable-bzlib
 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-
 iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-
 ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libmp3lame --enable-
 libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-
 libx265 --enable-libdav1d --disable-debug --enable-fontconfig --enable-
 libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-
 libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
 libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex
 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-
 amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-
 libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid
 --enable-libaom --enable-libopenmpt --enable-version3 --enable-libsvthevc
 --enable-libkvazaar --enable-libxavs --enable-libzmq --enable-libvmaf
 --enable-vapoursynth --enable-librav1e --enable-mbedtls --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-
 cflags=-DZMQ_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv
 --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
   libavutil      56. 36.101 / 56. 36.101
   libavcodec     58. 64.101 / 58. 64.101
   libavformat    58. 35.100 / 58. 35.100
   libavdevice    58.  9.101 / 58.  9.101
   libavfilter     7. 67.100 /  7. 67.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 Input #0, matroska,webm, from 'C:\Users\Selur\Desktop\Sample_7Ch-001.mkv':
   Metadata:
     encoder         : libebml v1.3.10 + libmatroska v1.5.2
     creation_time   : 2019-12-28T21:56:35.000000Z
   Duration: 00:01:02.32, start: 0.000000, bitrate: 13685 kb/s
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
     Metadata:
       BPS-eng         : 9770973
       DURATION-eng    : 00:01:02.271000000
       NUMBER_OF_FRAMES-eng: 1493
       NUMBER_OF_BYTES-eng: 76056040
       _STATISTICS_WRITING_APP-eng: mkvmerge v41.0.0.27 ('Smarra') 64-bit
       _STATISTICS_WRITING_DATE_UTC-eng: 2019-12-28 21:56:35
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
     Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 6.1, s32p (24 bit)
 (default)
     Metadata:
       BPS-eng         : 3917291
       DURATION-eng    : 00:01:02.315000000
       NUMBER_OF_FRAMES-eng: 5842
       NUMBER_OF_BYTES-eng: 30513256
       _STATISTICS_WRITING_APP-eng: mkvmerge v41.0.0.27 ('Smarra') 64-bit
       _STATISTICS_WRITING_DATE_UTC-eng: 2019-12-28 21:56:35
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
 Output #0, h264, to 'E:\Output\Sample_7Ch-001_11_35_02_4510_01.264':
   Metadata:
     encoder         : Lavf58.35.100
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
 (default)
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 frame= 1493 fps=1406 q=-1.0 Lsize=   74241kB time=00:01:02.22
 bitrate=9773.3kbits/s speed=58.6x
 video:74241kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.000000%
 }}}

 2. Use
 {{{
 ffmpeg -y  -r 24000/1001 -i "Sample_7Ch-001_11_35_02_4510_01.264" -vcodec
 copy -map 0:0 -bsf:v h264_mp4toannexb -vtag avc1 -aspect 177778:100000 -r
 24000/1001 "Sample_7Ch.mkv"
 }}}
 to multiplex the raw h264 video into an mkv file.

 For me this fails with:
 {{{
 ffmpeg -y  -r 24000/1001 -i "E:\Output\Sample_7Ch-
 001_11_35_02_4510_01.264" -vcodec copy -map 0:0 -bsf:v h264_mp4toannexb
 -vtag avc1 -aspect 177778:100000 -r 24000/1001 "E:\Output\Sample_7Ch.mkv"
 ffmpeg version N-95921-g8067c0c2eb-ge5db2e96c0+3 Copyright (c) 2000-2019
 the FFmpeg developers
   built with gcc 9.2.0 (Rev2, Built by MSYS2 project)
   configuration:  --disable-autodetect --enable-amf --enable-bzlib
 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-
 iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-
 ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libmp3lame --enable-
 libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-
 libx265 --enable-libdav1d --disable-debug --enable-fontconfig --enable-
 libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-
 libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
 libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex
 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-
 amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-
 libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid
 --enable-libaom --enable-libopenmpt --enable-version3 --enable-libsvthevc
 --enable-libkvazaar --enable-libxavs --enable-libzmq --enable-libvmaf
 --enable-vapoursynth --enable-librav1e --enable-mbedtls --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-
 cflags=-DZMQ_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv
 --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
   libavutil      56. 36.101 / 56. 36.101
   libavcodec     58. 64.101 / 58. 64.101
   libavformat    58. 35.100 / 58. 35.100
   libavdevice    58.  9.101 / 58.  9.101
   libavfilter     7. 67.100 /  7. 67.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 [h264 @ 000001f6fed92f00] Stream #0: not enough frames to estimate rate;
 consider increasing probesize
 Input #0, h264, from 'E:\Output\Sample_7Ch-001_11_35_02_4510_01.264':
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1200k tbn, 47.95 tbc
 Overriding aspect ratio with stream copy may produce invalid files
 Output #0, matroska, to 'E:\Output\Sample_7Ch.mkv':
   Metadata:
     encoder         : Lavf58.35.100
     Stream #0:0: Video: h264 (High) (avc1 / 0x31637661),
 yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps,
 23.98 tbr, 1k tbn, 23.98 tbc
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 [matroska @ 000001f6ff38f040] Timestamps are unset in a packet for stream
 0. This is deprecated and will stop working in the future. Fix your code
 to set the timestamps properly
 [matroska @ 000001f6ff38f040] Can't write packet with unknown timestamp
 av_interleaved_write_frame(): Invalid argument
 frame=    1 fps=0.0 q=-1.0 Lsize=       1kB time=-00:00:00.04 bitrate=N/A
 speed=N/A
 video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 }}}

 Note:
 I also tried .m2ts as output which fails the same way, using mp4 as output
 container on the other hand complains, but doesn't abort:
 {{{
 ffmpeg version N-95921-g8067c0c2eb-ge5db2e96c0+3 Copyright (c) 2000-2019
 the FFmpeg developers
   built with gcc 9.2.0 (Rev2, Built by MSYS2 project)
   configuration:  --disable-autodetect --enable-amf --enable-bzlib
 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-
 iconv --enable-lzma --enable-nvenc --enable-zlib --enable-sdl2 --enable-
 ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libmp3lame --enable-
 libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-
 libx265 --enable-libdav1d --disable-debug --enable-fontconfig --enable-
 libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-
 libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
 libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex
 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-
 amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-
 libzimg --enable-libshine --enable-gpl --enable-avisynth --enable-libxvid
 --enable-libaom --enable-libopenmpt --enable-version3 --enable-libsvthevc
 --enable-libkvazaar --enable-libxavs --enable-libzmq --enable-libvmaf
 --enable-vapoursynth --enable-librav1e --enable-mbedtls --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-
 cflags=-DZMQ_STATIC --extra-cflags=-DLIBXML_STATIC --extra-libs=-liconv
 --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
   libavutil      56. 36.101 / 56. 36.101
   libavcodec     58. 64.101 / 58. 64.101
   libavformat    58. 35.100 / 58. 35.100
   libavdevice    58.  9.101 / 58.  9.101
   libavfilter     7. 67.100 /  7. 67.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 [h264 @ 000001d96c622f00] Stream #0: not enough frames to estimate rate;
 consider increasing probesize
 Input #0, h264, from 'E:\Output\Sample_7Ch-001_11_35_02_4510_01.264':
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1200k tbn, 47.95 tbc
 Overriding aspect ratio with stream copy may produce invalid files
 Output #0, mp4, to 'E:\Output\Sample_7Ch.mp4':
   Metadata:
     encoder         : Lavf58.35.100
     Stream #0:0: Video: h264 (High) (avc1 / 0x31637661),
 yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps,
 23.98 tbr, 24k tbn, 23.98 tbc
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 [mp4 @ 000001d96cc8f040] Timestamps are unset in a packet for stream 0.
 This is deprecated and will stop working in the future. Fix your code to
 set the timestamps properly
 [mp4 @ 000001d96cc8f040] pts has no value
     Last message repeated 283 times
 [mp4 @ 000001d96cc8f040] pts has no valueB time=00:00:11.76
 bitrate=26210.4kbits/s speed=23.5x
     Last message repeated 309 times
 [mp4 @ 000001d96cc8f040] pts has no valueB time=00:00:24.69
 bitrate=18430.8kbits/s speed=24.6x
     Last message repeated 335 times
 [mp4 @ 000001d96cc8f040] pts has no valueB time=00:00:38.70
 bitrate=12028.5kbits/s speed=25.8x
     Last message repeated 339 times
 [mp4 @ 000001d96cc8f040] pts has no valueB time=00:00:52.88
 bitrate=8803.2kbits/s speed=26.4x
     Last message repeated 222 times
 frame= 1493 fps=630 q=-1.0 Lsize=   74253kB time=00:01:02.18
 bitrate=9781.4kbits/s speed=26.2x
 video:74241kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.016181%
 }}}

 Since neither adding '-r 24000/1001' nor additionally adding '-fflags
 +genpts' and muxing the files using mkvmerge works fine I guess this is
 either a bug in ffmpeg or I need some help since I don't know how to do
 this properly.
 => If this is not a bug please tell me how to multiplex raw H.264 to mkv
 and m2ts.

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


More information about the FFmpeg-trac mailing list