Neil Galiaskarov
Neil Galiaskarov

Reputation: 5073

How to calculate the start time of mp4 video?

I am studying mp4 video structure. I have an issue with reading the start time value for the following mp4 video

I have read this answer mp4 video starts at different time on Quicktime/AVplayer vs Chrome/Firefox

and it says that Edit atom can modify the start time.

Using ffprobe I have the following output:

    "start_time": "0.033333",
    "duration_ts": 327,
    "duration": "10.900000",
    "bit_rate": "9420949",

Using mp4dumper I have the following atoms structure which proves missing Edit atom file:

ftyp (24 @ 0)
free (8 @ 24)
moov (7034 @ 32)
  mvhd (108 @ 40)
  trak (2883 @ 148)
      tkhd (92 @ 156)
      mdia (2783 @ 248)
          mdhd (32 @ 256)
          hdlr (52 @ 288)
          minf (2691 @ 340)
              smhd (16 @ 348)
              dinf (36 @ 364)
                  dref (28 @ 372)
                      url  (12 @ 388)
              stbl (2631 @ 400)
                  stsd (91 @ 408)
                      mp4a (75 @ 424)
                  stts (24 @ 499)
                  stsc (304 @ 523)
                  stsz (2056 @ 827)
                  stco (148 @ 2883)
  trak (4035 @ 3031)
      tkhd (92 @ 3039)
      mdia (3935 @ 3131)
          mdhd (32 @ 3139)
          hdlr (52 @ 3171)
          minf (3843 @ 3223)
              vmhd (20 @ 3231)
              dinf (36 @ 3251)
                  dref (28 @ 3259)
                      url  (12 @ 3275)
              stbl (3779 @ 3287)
                  stsd (163 @ 3295)
                      avc1 (147 @ 3311)
                  stts (24 @ 3458)
                  ctts (1960 @ 3482)
                  stsc (40 @ 5442)
                  stsz (1328 @ 5482)
                  stco (148 @ 6810)
                  stss (108 @ 6958)
mdat (13096745 @ 7066)

How ffprobe calculates 0.033333 start time value?

Upvotes: 4

Views: 774

Answers (1)

Gyan
Gyan

Reputation: 92928

In this file, the video track timebase is 1/30, there is no edit list, and the first video sample has an offset of 1 in the ctts table. So, the pts of the first video sample is dts of 0 + ctts of 1 = 1 in TB units, which in absolute time is 1 * 1/30 = 0.03333. There are no frames with an earlier pts, so that is the track start time.

Upvotes: 5

Related Questions