videojs / m3u8-parser

An m3u8 parser.
Other
471 stars 98 forks source link

feat: add raw list of segment lines to manifest #145

Open jeff-transmit opened 3 years ago

jeff-transmit commented 3 years ago

Feature #49

Adds raw segment lines to the parsed manifest.

Playlist:

#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:10
#EXTINF:10,
media-00001.ts
#EXTINF:10,
media-00002.ts
#EXTINF:10,
media-00003.ts
#EXTINF:10,
media-00004.ts
#EXT-X-ENDLIST

Parsed output:

{
  allowCache: true,
  mediaSequence: 0,
  playlistType: 'VOD',
  segments: [
    {
      duration: 10,
      raw: [
        '#EXTINF:10,',
        'media-00001.ts'
      ],
      timeline: 0,
      uri: 'media-00001.ts'
    },
    {
      duration: 10,
      raw: [
        '#EXTINF:10,',
        'media-00002.ts'
      ],
      timeline: 0,
      uri: 'media-00002.ts'
    },
    {
      duration: 10,
      raw: [
        '#EXTINF:10,',
        'media-00003.ts'
      ],
      timeline: 0,
      uri: 'media-00003.ts'
    },
    {
      duration: 10,
      raw: [
        '#EXTINF:10,',
        'media-00004.ts'
      ],
      timeline: 0,
      uri: 'media-00004.ts'
    }
  ],
  targetDuration: 10,
  endList: true,
  discontinuitySequence: 0,
  discontinuityStarts: []
}
gkatsev commented 3 years ago

Can you provide more info on why this would be useful?

gkatsev commented 3 years ago

Ah, missed the link to the issue.

gkatsev commented 3 years ago

I think my main concern here is that we often have memory issues in VHS and keeping around even more strings is going to exacerbate it.

gkatsev commented 3 years ago

One alternative would be to feature flag this and make it default off and then if someone needs it, they can have it.

I think a concrete usecase would be nice, though.

jeff-transmit commented 3 years ago

One alternative would be to feature flag this and make it default off and then if someone needs it, they can have it.

I think a concrete usecase would be nice, though.

In our case, we need to be able to change and rebuild the playlist after using the parsed playlist and it would be more efficient to do this with the raw segment lines rather than processing the whole playlist again.

gkatsev commented 3 years ago

Are you using m3u8-parser directly or via VHS?

jeff-transmit commented 3 years ago

Are you using m3u8-parser directly or via VHS?

We are using it directly.

peterblazejewicz commented 2 years ago

IIMO there could be a pluggable metod to create event data or could be via events allowing to movidy events/source as callback, kind of the data parser for custom tari. No constructor changes (imagine, next version requires new param, actual core feature, this time required, to be added or removed)