Parsing m3u file : separate live tv from Vod

1.2k Views Asked by At

I'm currently working on an Iptv player app, and i have managed to parse the m3u file, the problem now that i want to separate live tv from Vod, i don't know when live tv channels ends and the Vod begins in the playlists

here are the keys of every object after the parsing is complete [ 'duration', 'title', 'tvgId', 'tvgName', 'tvgLogo', 'groupTitle' ] i'm using nestJs and m3u8-file-parser library for m3u parsing

1

There are 1 best solutions below

0
thornfish On

I'm assuming that your question is about HLS video. The short answer is that there's nothing in the HLS specification that lets you determine whether content is live. The stream types do lead to some confusion about that

the specification defines 3 types of streams: VOD, LIVE, and EVENT.

  • VOD streams, which have the following characteristics:

    • The m3u8 manifest bears the tag #EXT-X-PLAYLIST-TYPE:VOD
    • The playlist does not change.
    • The playlist contains all the segments in the video
  • LIVE streams, which have the following characteristics:

    • They DO NOT have an EXT-X-PLAYLIST-TYPE tag
    • The playlist changes over time and the client (player) is responsible for re-requesting the manifest periodically.
    • The playlist represents only a 'sliding window' into the video content. As video plays out, the earliest segments will 'fall off' and newer segments will appear.
  • EVENT streams, which have the following characteristics:

    • They bear the EXT-X-PLAYLIST-TYPE: EVENT tag
    • The playlist changes over time and the client (player) is responsible for re-requesting the manifest periodically.
    • The playlist represents all the video from the starting time of the event until the current time. That is, it constantly grows and the oldest segments never 'fall off'.

We need to distinguish between the LIVE stream type and 'liveness' as we usually think about it. As we noted above, a LIVE stream type just means that the stream is being presented as a sliding window with old segments falling off and new segments being added, whereas a VOD stream type has all the segments listed in the manifest and it never changes.

This is different from our usual conception of 'liveness' where we think that the content of the video is happening 'right now' (or perhaps almost 'right now', allowing for some latency)

I know of at least one commercial HLS server product that uses LIVE stream type to dynamically create a stream that is a combination of live ('right now') content and prerecorded stored content by concatenating the segments in a single stream.

Since the originator of the stream can do this at their pleasure, and since the HLS spec doesn't offer any guidance about describing the 'liveness' of the content, you will only be able to determine if content is really live if the originator of the stream uses custom tags or naming or other conventions to indicate when LIVE and VOD content start and end. In my experience, that does not commonly happen.