[FFmpeg-trac] #9124(undetermined:new): 24fps nut file converts to 24.39fps mkv?

FFmpeg trac at avcodec.org
Wed Feb 24 14:52:56 EET 2021


#9124: 24fps nut file converts to 24.39fps mkv?
--------------------------------------+----------------------------------
             Reporter:  ltratt        |                     Type:  defect
               Status:  new           |                 Priority:  normal
            Component:  undetermined  |                  Version:
             Keywords:                |               Blocked By:
             Blocking:                |  Reproduced by developer:  0
Analyzed by developer:  0             |
--------------------------------------+----------------------------------
 I created a simple video creation system that uses ffmpeg for everything
 (recording, editing, etc) called Aeschylus
 https://github.com/ltratt/aeschylus

 As part of that I seem to have found a case where ffmpeg 4.3.2 converts a
 24fps
 nut file to a 24.39fps mkv although, weirdly, it seems to lead to a 24fps
 mp4.
 You can see the problem with the video at https://tratt.net/scene_1.nut

 Output from ffprobe for the original .nut file:

 {{{
   Input #0, nut, from 'scene_1.nut':
     Metadata:
       encoder         : Lavf58.45.100
     Duration: 00:01:08.49, start: 0.000000, bitrate: 7657 kb/s
       Stream #0:0: Audio: flac ([172][241][0][0] / 0xF1AC), 44100 Hz,
 mono, s16 (default)
       Metadata:
         encoder         : Lavc58.91.100 flac
       Stream #0:1: Video: h264 (High 4:4:4 Predictive) (H264 /
 0x34363248), yuv420p, 1920x1080, 24 fps, 24 tbr, 49152 tbn, 48 tbc
 (default)
       Metadata:
         encoder         : Lavc58.91.100 libx264
 }}}

 and then if we look at the first couple of video packets we can see that
 each
 has a duration of 0.041667 seconds (i.e. 1/24 of a second):

 {{{
   frames.frame.0.media_type="video"
   frames.frame.0.stream_index=1
   frames.frame.0.key_frame=1
   frames.frame.0.pkt_pts=0
   frames.frame.0.pkt_pts_time="0.000000"
   frames.frame.0.pkt_dts=0
   frames.frame.0.pkt_dts_time="0.000000"
   frames.frame.0.best_effort_timestamp=0
   frames.frame.0.best_effort_timestamp_time="0.000000"
   frames.frame.0.pkt_duration=2048
   frames.frame.0.pkt_duration_time="0.041667"
   frames.frame.0.pkt_pos="1328"
   frames.frame.0.pkt_size="239333"
   frames.frame.0.width=1920
   frames.frame.0.height=1080
   frames.frame.0.pix_fmt="yuv420p"
   frames.frame.0.sample_aspect_ratio="1:1"
   frames.frame.0.pict_type="I"
   frames.frame.0.coded_picture_number=0
   frames.frame.0.display_picture_number=0
   frames.frame.0.interlaced_frame=0
   frames.frame.0.top_field_first=0
   frames.frame.0.repeat_pict=0
   frames.frame.0.color_range="unknown"
   frames.frame.0.color_space="unknown"
   frames.frame.0.color_primaries="unknown"
   frames.frame.0.color_transfer="unknown"
   frames.frame.0.chroma_location="left"
   frames.frame.1.media_type="video"
   frames.frame.1.stream_index=1
   frames.frame.1.key_frame=0
   frames.frame.1.pkt_pts=2048
   frames.frame.1.pkt_pts_time="0.041667"
   frames.frame.1.pkt_dts=2048
   frames.frame.1.pkt_dts_time="0.041667"
   frames.frame.1.best_effort_timestamp=2048
   frames.frame.1.best_effort_timestamp_time="0.041667"
   frames.frame.1.pkt_duration=2048
   frames.frame.1.pkt_duration_time="0.041667"
   frames.frame.1.pkt_pos="241483"
   frames.frame.1.pkt_size="215575"
   frames.frame.1.width=1920
   frames.frame.1.height=1080
   frames.frame.1.pix_fmt="yuv420p"
   frames.frame.1.sample_aspect_ratio="1:1"
   frames.frame.1.pict_type="P"
   frames.frame.1.coded_picture_number=1
   frames.frame.1.display_picture_number=0
   frames.frame.1.interlaced_frame=0
   frames.frame.1.top_field_first=0
   frames.frame.1.repeat_pict=0
   frames.frame.1.color_range="unknown"
   frames.frame.1.color_space="unknown"
   frames.frame.1.color_primaries="unknown"
   frames.frame.1.color_transfer="unknown"
   frames.frame.1.chroma_location="left"
 }}}

 If we convert it into an mp4 with:

 {{{
   $ ffmpeg -i scene_1.nut out.mp4
 }}}

 we get:

 {{{
   Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf58.45.100
     Duration: 00:01:08.51, start: 0.000000, bitrate: 320 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
 1920x1080, 244 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
 mono, fltp, 69 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
 }}}

 and the first couple of packets again we have frames 1/24 of a second
 long:

 {{{
   frames.frame.0.media_type="video"
   frames.frame.0.stream_index=0
   frames.frame.0.key_frame=1
   frames.frame.0.pkt_pts=0
   frames.frame.0.pkt_pts_time="0.000000"
   frames.frame.0.pkt_dts=0
   frames.frame.0.pkt_dts_time="0.000000"
   frames.frame.0.best_effort_timestamp=0
   frames.frame.0.best_effort_timestamp_time="0.000000"
   frames.frame.0.pkt_duration=512
   frames.frame.0.pkt_duration_time="0.041667"
   frames.frame.0.pkt_pos="48"
   frames.frame.0.pkt_size="15038"
   frames.frame.0.width=1920
   frames.frame.0.height=1080
   frames.frame.0.pix_fmt="yuv420p"
   frames.frame.0.sample_aspect_ratio="N/A"
   frames.frame.0.pict_type="I"
   frames.frame.0.coded_picture_number=0
   frames.frame.0.display_picture_number=0
   frames.frame.0.interlaced_frame=0
   frames.frame.0.top_field_first=0
   frames.frame.0.repeat_pict=0
   frames.frame.0.color_range="unknown"
   frames.frame.0.color_space="unknown"
   frames.frame.0.color_primaries="unknown"
   frames.frame.0.color_transfer="unknown"
   frames.frame.0.chroma_location="left"
   frames.frame.1.media_type="video"
   frames.frame.1.stream_index=0
   frames.frame.1.key_frame=0
   frames.frame.1.pkt_pts=512
   frames.frame.1.pkt_pts_time="0.041667"
   frames.frame.1.pkt_dts=512
   frames.frame.1.pkt_dts_time="0.041667"
   frames.frame.1.best_effort_timestamp=512
   frames.frame.1.best_effort_timestamp_time="0.041667"
   frames.frame.1.pkt_duration=512
   frames.frame.1.pkt_duration_time="0.041667"
   frames.frame.1.pkt_pos="19190"
   frames.frame.1.pkt_size="254"
   frames.frame.1.width=1920
   frames.frame.1.height=1080
   frames.frame.1.pix_fmt="yuv420p"
   frames.frame.1.sample_aspect_ratio="N/A"
   frames.frame.1.pict_type="B"
   frames.frame.1.coded_picture_number=3
   frames.frame.1.display_picture_number=0
   frames.frame.1.interlaced_frame=0
   frames.frame.1.top_field_first=0
   frames.frame.1.repeat_pict=0
   frames.frame.1.color_range="unknown"
   frames.frame.1.color_space="unknown"
   frames.frame.1.color_primaries="unknown"
   frames.frame.1.color_transfer="unknown"
   frames.frame.1.chroma_location="left"
 }}}

 However if we convert it to a .mkv:

 {{{
   $ ffmpeg -i scene_1.nut out.mkv
 }}}

 then we get:

 {{{
   Input #0, matroska,webm, from 'out.mkv':
     Metadata:
       ENCODER         : Lavf58.45.100
     Duration: 00:01:08.49, start: 0.000000, bitrate: 322 kb/s
       Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 24
 fps, 24 tbr, 1k tbn, 48 tbc (default)
       Metadata:
         ENCODER         : Lavc58.91.100 libx264
         DURATION        : 00:01:08.459000000
       Stream #0:1: Audio: vorbis, 44100 Hz, mono, fltp (default)
       Metadata:
         ENCODER         : Lavc58.91.100 libvorbis
         DURATION        : 00:01:08.488000000
 }}}

 and the first two packets have a duration of 0.41000 seconds (roughly
 equivalent to 24.36fps):

 {{{
   frames.frame.0.media_type="video"
   frames.frame.0.stream_index=0
   frames.frame.0.key_frame=1
   frames.frame.0.pkt_pts=0
   frames.frame.0.pkt_pts_time="0.000000"
   frames.frame.0.pkt_dts=0
   frames.frame.0.pkt_dts_time="0.000000"
   frames.frame.0.best_effort_timestamp=0
   frames.frame.0.best_effort_timestamp_time="0.000000"
   frames.frame.0.pkt_duration=41
   frames.frame.0.pkt_duration_time="0.041000"
   frames.frame.0.pkt_pos="4124"
   frames.frame.0.pkt_size="15038"
   frames.frame.0.width=1920
   frames.frame.0.height=1080
   frames.frame.0.pix_fmt="yuv420p"
   frames.frame.0.sample_aspect_ratio="N/A"
   frames.frame.0.pict_type="I"
   frames.frame.0.coded_picture_number=0
   frames.frame.0.display_picture_number=0
   frames.frame.0.interlaced_frame=0
   frames.frame.0.top_field_first=0
   frames.frame.0.repeat_pict=0
   frames.frame.0.color_range="unknown"
   frames.frame.0.color_space="unknown"
   frames.frame.0.color_primaries="unknown"
   frames.frame.0.color_transfer="unknown"
   frames.frame.0.chroma_location="left"
   frames.frame.1.media_type="video"
   frames.frame.1.stream_index=0
   frames.frame.1.key_frame=0
   frames.frame.1.pkt_pts=42
   frames.frame.1.pkt_pts_time="0.042000"
   frames.frame.1.pkt_dts=42
   frames.frame.1.pkt_dts_time="0.042000"
   frames.frame.1.best_effort_timestamp=42
   frames.frame.1.best_effort_timestamp_time="0.042000"
   frames.frame.1.pkt_duration=41
   frames.frame.1.pkt_duration_time="0.041000"
   frames.frame.1.pkt_pos="23299"
   frames.frame.1.pkt_size="254"
   frames.frame.1.width=1920
   frames.frame.1.height=1080
   frames.frame.1.pix_fmt="yuv420p"
   frames.frame.1.sample_aspect_ratio="N/A"
   frames.frame.1.pict_type="B"
   frames.frame.1.coded_picture_number=3
   frames.frame.1.display_picture_number=0
   frames.frame.1.interlaced_frame=0
   frames.frame.1.top_field_first=0
   frames.frame.1.repeat_pict=0
   frames.frame.1.color_range="unknown"
   frames.frame.1.color_space="unknown"
   frames.frame.1.color_primaries="unknown"
   frames.frame.1.color_transfer="unknown"
   frames.frame.1.chroma_location="left"
 }}}

 Notice also that the timestamp of the second packet is 0.042000. It feels
 like,
 perhaps, the duration of the first frame is being rounded down but the
 timestamp of the second frame is being rounded up? This video appears
 notably
 desynchronised when played, presumably because of this problem.

 It is quite probable that I'm doing something stupid somewhere in the
 pipeline,
 but I suspect this is still a surprising outcome?


 Laurie

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


More information about the FFmpeg-trac mailing list