[FFmpeg-trac] #7927(undetermined:new): Video copy from mkv to mp4 causes variable frame rate from constant frame rate

FFmpeg trac at avcodec.org
Mon May 27 16:54:10 EEST 2019


#7927: Video copy from mkv to mp4 causes variable frame rate from constant frame
rate
-------------------------------------+-------------------------------------
             Reporter:  madsfoto     |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:  git-
  undetermined                       |  master
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 I am trying to convert from MKV to MP4 or MOV with a constant frame rate
 and the resulting file has a variable frame rate.
 In running ffmpeg -i FILE.mkv -c:v copy FILE.mp4, I expect a pure
 container switch, and that the frame rate to stay exactly the same. The
 reverse (mp4 to mkv) causes ''no'' frame rate change.

 In mediainfo for source:
 Frame rate mode                : Constant
 Frame rate                     : 29.970 (30000/1001) FPS

 In mediainfo for destination:
 Frame rate mode                : Variable
 Frame rate                     : 31.946 FPS
 Minimum frame rate             : 27.778 FPS
 Maximum frame rate             : 16 000.000 FPS
 Original frame rate            : 29.970 (30000/1001) FPS


 The command I use is: ffmpeg.exe -i
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv -c:v copy -an
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4

 I have a 2.63 MB mkv file for reproduction available, output of video copy
 is as below:


 ffmpeg -v 9 -loglevel 99 -i
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv -c:v copy -an
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4
 ffmpeg version N-93913-g1a74b04737 Copyright (c) 2000-2019 the FFmpeg
 developers
   built with gcc 8.3.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 --disable-
 debug --enable-ffnvcodec --enable-nvdec --enable-libmp3lame --enable-
 libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-
 libx265 --enable-libdav1d --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-mbedtls --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-
 cflags=-DLIBXML_STATIC --extra-libs=-liconv
   libavutil      56. 28.100 / 56. 28.100
   libavcodec     58. 52.102 / 58. 52.102
   libavformat    58. 27.103 / 58. 27.103
   libavdevice    58.  7.100 / 58.  7.100
   libavfilter     7. 54.101 /  7. 54.101
   libswscale      5.  4.101 /  5.  4.101
   libswresample   3.  4.100 /  3.  4.100
   libpostproc    55.  4.100 / 55.  4.100
 Splitting the commandline.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-i' ... matched as input url with argument
 'Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv'.
 Reading option '-c:v' ... matched as option 'c' (codec name) with argument
 'copy'.
 Reading option '-an' ... matched as option 'an' (disable audio) with
 argument '1'.
 Reading option 'Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4'
 ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Successfully parsed a group of options.
 Parsing a group of options: input url
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv.
 Successfully parsed a group of options.
 Opening an input file:
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv.
 [NULL @ 000001dd98e32b40] Opening
 'Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv' for reading
 [file @ 000001dd98e33c40] Setting default whitelist 'file,crypto'
 Probing matroska,webm score:100 size:2048
 [matroska,webm @ 000001dd98e32b40] Format matroska,webm probed with
 size=2048 and score=100
 st:0 removing common factor 1000000 from timebase
 st:1 removing common factor 1000000 from timebase
 [matroska,webm @ 000001dd98e32b40] Before avformat_find_stream_info() pos:
 4934 bytes read:32768 seeks:0 nb_streams:2
 [h264 @ 000001dd98e36800] nal_unit_type: 7(SPS), nal_ref_idc: 3
 [h264 @ 000001dd98e36800] nal_unit_type: 8(PPS), nal_ref_idc: 3
 [h264 @ 000001dd98e36800] nal_unit_type: 7(SPS), nal_ref_idc: 3
 [h264 @ 000001dd98e36800] nal_unit_type: 8(PPS), nal_ref_idc: 3
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 5(IDR), nal_ref_idc: 3
 [h264 @ 000001dd98e36800] Format yuvj420p chosen by get_format().
 [h264 @ 000001dd98e36800] Reinit context to 1920x1088, pix_fmt: yuvj420p
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] no picture ooo
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] no picture ooo
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 2
 [h264 @ 000001dd98e36800] no picture
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 2
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 9(AUD), nal_ref_idc: 0
 [h264 @ 000001dd98e36800] nal_unit_type: 1(Coded slice of a non-IDR
 picture), nal_ref_idc: 2
 [matroska,webm @ 000001dd98e32b40] All info found
 [matroska,webm @ 000001dd98e32b40] stream 0: start_time: 0.067 duration:
 -9223372036854776.000
 [matroska,webm @ 000001dd98e32b40] stream 1: start_time: 0.000 duration:
 -9223372036854776.000
 [matroska,webm @ 000001dd98e32b40] format: start_time: 0.000 duration:
 1.104 bitrate=20018 kb/s
 [matroska,webm @ 000001dd98e32b40] After avformat_find_stream_info() pos:
 1040235 bytes read:1057837 seeks:0 frames:28
 Input #0, matroska,webm, from
 'Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv':
   Metadata:
     COMPATIBLE_BRANDS: qt  niko
     MAJOR_BRAND     : qt
     MINOR_VERSION   : 537331968
     ENCODER         : Lavf58.27.103
   Duration: 00:00:01.10, start: 0.000000, bitrate: 20018 kb/s
     Stream #0:0(eng), 11, 1/1000: Video: h264 (High), 1 reference frame,
 yuvj420p(pc, smpte170m/bt709/bt470m, progressive, left), 1920x1080
 (1920x1088), 0/1, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
     Metadata:
       DURATION        : 00:00:01.104000000
     Stream #0:1(eng), 17, 1/1000: Audio: vorbis, 48000 Hz, stereo, fltp
 (default)
     Metadata:
       ENCODER         : Lavc58.52.102 libvorbis
       DURATION        : 00:00:01.003000000
 Successfully opened the file.
 Parsing a group of options: output url
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4.
 Applying option c:v (codec name) with argument copy.
 Applying option an (disable audio) with argument 1.
 Successfully parsed a group of options.
 Opening an output file:
 Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4.
 [file @ 000001dd99b6b040] Setting default whitelist 'file,crypto'
 Successfully opened the file.
 Output #0, mp4, to
 'Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4':
   Metadata:
     COMPATIBLE_BRANDS: qt  niko
     MAJOR_BRAND     : qt
     MINOR_VERSION   : 537331968
     encoder         : Lavf58.27.103
     Stream #0:0(eng), 0, 1/16000: Video: h264 (High), 1 reference frame
 (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt709/bt470m, progressive,
 left), 1920x1080 (0x0), 0/1, q=2-31, 29.97 fps, 29.97 tbr, 16k tbn, 1k tbc
 (default)
     Metadata:
       DURATION        : 00:00:01.104000000
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless
 if it occurs once at the start per stream)
 [mp4 @ 000001dd98f72880] Non-monotonous DTS in output stream 0:0;
 previous: 538, current: 48; changing to 539. This may result in incorrect
 timestamps in the output file.
 [matroska,webm @ 000001dd98e32b40] Element at 0x2a26fb ending at 0x2a2739
 exceeds containing master element ending at 0x2a26f6
 No more output streams to write to, finishing.
 frame=   31 fps=0.0 q=-1.0 Lsize=    2680kB time=00:00:00.97
 bitrate=22608.3kbits/s speed=13.6x
 video:2679kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.049911%
 Input file #0 (Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mkv):
   Input stream #0:0 (video): 31 packets read (2742890 bytes);
   Input stream #0:1 (audio): 17 packets read (4456 bytes);
   Total: 48 packets (2747346 bytes) demuxed
 Output file #0
 (Convert_to_mp4_ConstantFramerate_to_VariableFramerate.mp4):
   Output stream #0:0 (video): 31 packets muxed (2742890 bytes);
   Total: 31 packets (2742890 bytes) muxed
 0 frames successfully decoded, 0 decoding errors
 [AVIOContext @ 000001dd9911e980] Statistics: 2 seeks, 14 writeouts
 [AVIOContext @ 000001dd98e3bec0] Statistics: 2762553 bytes read, 0 seeks

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


More information about the FFmpeg-trac mailing list