videojs / m3u8-parser

An m3u8 parser.
Other
471 stars 98 forks source link

EXT-X-MAP not added to manifest #160

Closed mattpepin closed 1 year ago

mattpepin commented 1 year ago

EXT-X-MAP is not parsed correctly. It does not appear in the parsed output. This is because the map() function does not add anything to the manifest:

https://github.com/videojs/m3u8-parser/blob/main/src/parser.js#L368

gkatsev commented 1 year ago

Each segment gets a map property that points at the relevant map https://github.com/videojs/m3u8-parser/blob/main/src/parser.js#L654-L655

See the example in the README https://github.com/videojs/m3u8-parser#parsed-output

mattpepin commented 1 year ago

What if it's an init segment for fragmented MP4?

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-MAP:URI="init.mp4"
#EXTINF:8.333333,
index0.m4s
#EXTINF:8.333333,
index1.m4s
#EXTINF:8.333333,
index2.m4s
#EXTINF:8.333333,
index3.m4s

Edit: Oh... It's in the first segment, I see...

gkatsev commented 1 year ago

Oh, sorry, I should've made it more clear. The way that m3u8-parser models this is that the property is associated with the next segment that comes after it. So, in your example, it'll be the first segment. If there are multiple EXT-X-MAP, each segment following the tag would get the map property.

#EXT-X-MAP:URI="init.mp4"
#EXTINF:8.333333,
index0.m4s
#EXTINF:8.333333,
index1.m4s
#EXTINF:8.333333,
#EXT-X-MAP:URI="init2.mp4"
index2.m4s
#EXTINF:8.333333,
index3.m4s

So, index0 would have a map pointing at init and index2 would have a map pointing at init2.

mattpepin commented 1 year ago

Pretty cool! I didn't know the spec allowed this. Totally makes sense now! Thank you.

gkatsev commented 1 year ago

You're welcome. Yup, the spec allows for a new map per segment if you really wanted to, even! But I think most commonly you'll find it after a discontinuity.