So here I have an init segment: http://people.mozilla.org/~jyavenard/mediatest/fragmented/facebook-paper_dash.mp4
Now, all movie headers (mvhd atom), media header (mdhd) or track headers (tkhd atoms) indicate that the duration is 0.
(can check with this page: http://people.mozilla.org/~jyavenard/tests/mse_mp4/paper-init.html)
Yet, IE11 and Chrome reads the duration as 120.187s which makes sense as the original mp4 I extracted it from was 2 minutes long.
Here is the details of this mp4 init segment:
[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
I can't for the life of me figure out where it's getting that 120.187s duration...
Any ideas? thanks
You cannot determine the duration of an MP4 from the init segment only. More precisely, a fragmented MP4 (fMP4) does not have the required information about the entire presentation to compute the duration. You will need to read all the movie fragments, "moof boxes", and combine the durations to know the duration of the entire presentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With