Forum Discussion

rlutz's avatar
rlutz
Visitor
15 years ago

Simple HLS Question

If I've got an HLS stream that's live (the m3u8 is being updated on the fly), how can I get my app to start "live" instead of at the start of the playlist. I gave a cursory glance through the developer's guide, and saw StartTime and StreamStartTimeOffset, but that didn't seem to do the trick.

Anyway, if someone could just give me a quick reply I'd appreciate it.

3 Replies

  • I think I figured it out for myself, I thought, what would larry wall do, and put StreamStartTimeOffset:-1 and that seems to have done the trick 🙂
  • I think setting StreamStartTimeOffset=-1 is a red herring.... We don't really even use that parameter any more.

    The way to track the live point is to either create a "Live Windowed" HLS stream or use the "PlayStart" content meta-data parameter to specify the live point in an HLS stream that includes all the segments. Using the "PlayStart" parameter is much more complicated but allows the user to seek in the live stream.

    When using the "Sliding Window Live Playlist" approach, the .m3u8 specifies the "Live" point with the #EXT-X-MEDIA-SEQUENCE:Number tag that specifies the sequence number of the first segment in the current playlist. We recommend including 8 segments in your windowed live stream. An example is shown in section 8.3 of the HLS spec:

    8.3. Sliding Window Playlist, using HTTPS

    #EXTM3U
    #EXT-X-TARGETDURATION:8
    #EXT-X-MEDIA-SEQUENCE:2680

    #EXTINF:8,
    https://priv.example.com/fileSequence2680.ts
    #EXTINF:8,
    https://priv.example.com/fileSequence2681.ts
    #EXTINF:8,
    https://priv.example.com/fileSequence2682.ts

    If you are going to include all the segments in your playlist, you need to track the live point externally to the stream. You can then use the "PlayStart" content meta-data parameter to provide the offset in seconds from which the video is to be played. When using this method, be sure NOT to include the EXT-X-PROGRAM-DATE-TIME tag in the .m3u8 stream, as that tag changes the way the PlayStart parameter is interpreted.

    If you know the time your live stream starts in seconds since epoch (include it in your xml feed), brightscript can always get the current time and you can calculate the live point and "PlayStart" parameter as follows:

    liveTimeSinceEpoch = CreateObject("roDateTime").asSeconds()
    PlayStart = liveTimeSinceEpoch - streamStartTimeSinceEpoch


    --Kevin
  • Probably not appropriate, but I've found that setting the PlayStart to some absurdly high number also works, without the time calculation.