[FFmpeg-trac] #9775(undetermined:new): incorrect duration when start not zero

FFmpeg trac at avcodec.org
Mon May 9 23:06:49 EEST 2022


#9775: incorrect duration when start not zero
-------------------------------------+-------------------------------------
             Reporter:  delpeck      |                    Owner:  (none)
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  unspecified  |               Resolution:
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Comment (by Cosmin Stejerean):

 The actual values in the ticket don't match the attached segment (which is
 segment-3.ts instead of segment-5.ts) but I can reproduce the same
 problem. Here's the data on the attached segment

 {{{
 Duration: 00:00:07.35, start: 21.512000
 }}}

 encoded with ffmpeg < 4.4 and -copyts this reports

 {{
 Duration: 00:00:07.30, start: 21.566016
 }}

 encoded with ffmpeg 5.0 and -copyts his reports

 {{{
 Duration: 00:00:28.87, start: 21.566016
 }}}

 Digging into the two MP4 files I see that both versions have identical
 edit lists


 {{{
     [edts] size=8+40
       [elst] size=12+28
         entry_count = 2
         entry/segment duration = 21566
         entry/media time = -1
         entry/media rate = 1
         entry/segment duration = 7300
         entry/media time = 1024
         entry/media rate = 1
 }}}

 we see the empty edit which represents the start time. However the
 duration reported in the container, in mvhd and tkhd is different. Older
 ffmpeg reported only the media duration without the empty edit

 {{
 [moov]
   [mvhd]
     timescale = 1000
     duration = 7300
     duration(ms) = 7300
   [trak]
     [tkhd]
       enabled = 1
       id = 1
       duration = 7300
       width = 1920.000000
       height = 1080.000000
 }}

 whereas newer ffmpeg reports the entire duration with the start time
 offset of the empty edit.

 {{{
 [moov]
   [mvhd]
     timescale = 1000
     duration = 28867
     duration(ms) = 28867
   [trak]
     [tkhd]
       enabled = 1
       id = 1
       duration = 28867
       width = 1920.000000
       height = 1080.000000
 }}}

 This new duration at the container does seem to be correct in terms of the
 ISOBMFF spec

     Duration is an integer that indicates the duration of this track (in
 the timescale indicated in the Movie Header Box). The value of this field
 is equal to the sum of the durations of all of the track's edits. If there
 is no edit list, then the duration is the sum of the sample durations,
 converted into the timescale in the Movie Header Box

 But the net combination of reported start time and duration seems a bit
 confusing.

 {{{
 Duration: 00:00:28.87, start: 21.566016
 }}}

 I'd expect the final timestamp is going to be start time + duration, and
 the reported values don't add up. Furthermore we essentially have a TS
 file and an MP4 file that represent the same slice of a longer video with
 preserved timestamps and they report different values for start time and
 duration, which seems confusing.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9775#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list