如何从mp4 init段确定持续时间

时间:2015-01-08 05:03:59

标签: video mp4

所以这里我有一个init段: http://people.mozilla.org/~jyavenard/mediatest/fragmented/facebook-paper_dash.mp4

现在,所有电影标题(mvhd atom),媒体标题(mdhd)或曲目标题(tkhd atoms)都表示持续时间为0。

(可以查看此页面:http://people.mozilla.org/~jyavenard/tests/mse_mp4/paper-init.html

然而,IE11和Chrome将持续时间读为120.187s这是有意义的,因为我从中提取它的原始mp4是2分钟。

以下是此mp4 init段的详细信息:

    [ftyp] size=8+28
      major_brand = isom
      minor_version = 200
      compatible_brand = isom
      compatible_brand = iso2
      compatible_brand = avc1
      compatible_brand = mp41
      compatible_brand = dash
    [free] size=8+47
    [moov] size=8+1168
      [mvhd] size=12+96
        timescale = 1000
        duration = 0
        duration(ms) = 0
      [mvex] size=8+64
        [trex] size=12+20
          track id = 1
          default sample description index = 1
          default sample duration = 1001
          default sample size = 0
          default sample flags = 10000
        [trex] size=12+20
          track id = 2
          default sample description index = 1
          default sample duration = 1024
          default sample size = 0
          default sample flags = 0
      [trak] size=8+467
        [tkhd] size=12+80, flags=f
          enabled = 1
          id = 1
          duration = 0
          width = 1920.000000
          height = 1080.000000
        [mdia] size=8+367
          [mdhd] size=12+20
            timescale = 30000
            duration = 0
            duration(ms) = 0
            language = eng
          [hdlr] size=12+33
            handler_type = vide
            handler_name = VideoHandler
          [minf] size=8+282
            [vmhd] size=12+8, flags=1
              graphics_mode = 0
              op_color = 0000,0000,0000
            [dinf] size=8+28
              [dref] size=12+16
                [url ] size=12+0, flags=1
                  location = [local to file]
            [stbl] size=8+218
              [stsd] size=12+138
                entry-count = 1
                [avc1] size=8+126
                  data_reference_index = 1
                  width = 1920
                  height = 1080
                  compressor = 
                  [avcC] size=8+40
                    Configuration Version = 1
                    Profile = Main
                    Profile Compatibility = 40
                    Level = 31
                    NALU Length Size = 4
                    Sequence Parameter = [67 4d 40 1f ec c0 3c 01 13 f2 e0 22 00 00 07 d2 00 01 d4 c0 1e 30 63 34]
                    Picture Parameter = [68 e9 78 f2 c8]
              [stts] size=12+4
                entry_count = 0
              [stsc] size=12+4
                entry_count = 0
              [stsz] size=12+8
                sample_size = 0
                sample_count = 0
              [stco] size=12+4
                entry_count = 0
      [trak] size=8+407
        [tkhd] size=12+80, flags=f
          enabled = 1
          id = 2
          duration = 0
          width = 0.000000
          height = 0.000000
        [mdia] size=8+307
          [mdhd] size=12+20
            timescale = 48000
            duration = 0
            duration(ms) = 0
            language = eng
          [hdlr] size=12+33
            handler_type = soun
            handler_name = SoundHandler
          [minf] size=8+222
            [smhd] size=12+4
              balance = 0
            [dinf] size=8+28
              [dref] size=12+16
                [url ] size=12+0, flags=1
                  location = [local to file]
            [stbl] size=8+162
              [stsd] size=12+82
                entry-count = 1
                [mp4a] size=8+70
                  data_reference_index = 1
                  channel_count = 2
                  sample_size = 16
                  sample_rate = 48000
                  [esds] size=12+30
                    [ESDescriptor] size=2+28
                      es_id = 2
                      stream_priority = 0
                      [DecoderConfig] size=2+20
                        stream_type = 5
                        object_type = 64
                        up_stream = 0
                        buffer_size = 0
                        max_bitrate = 192082
                        avg_bitrate = 192082
                        DecoderSpecificInfo = 11 90 56 e5 00 
                      [Descriptor:06] size=2+1
              [stts] size=12+4
                entry_count = 0
              [stsc] size=12+4
                entry_count = 0
              [stsz] size=12+8
                sample_size = 0
                sample_count = 0
              [stco] size=12+4
                entry_count = 0
      [udta] size=8+90
        [meta] size=12+78
          [hdlr] size=12+21
            handler_type = mdir
            handler_name = 
          [ilst] size=8+37
            [.too] size=8+29
              [data] size=8+21
                type = 1
                lang = 0
                value = Lavf55.12.100

我不能为我的生活找出它在120.187s的持续时间......

有什么想法吗? 感谢

2 个答案:

答案 0 :(得分:0)

您不能仅从init段确定MP4的持续时间。更确切地说,碎片化的MP4(fMP4)没有有关整个演示文稿所需的信息来计算持续时间。您将需要阅读所有电影片段,“ momo box”,并组合持续时间以了解整个演示的持续时间。

答案 1 :(得分:0)

对于我来说,mp4.Moov.Mvhd.Duration / mp4.Moov.Mvhd.Timescale是实际的mp4时间(以秒为单位)。