Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rlutz
Visitor

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.
0 Kudos
4 REPLIES 4
rlutz
Visitor

Re: Simple HLS Question

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 🙂
0 Kudos
RokuKevin
Visitor

Re: Simple HLS Question

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
0 Kudos
TheEndless
Channel Surfer

Re: Simple HLS Question

Probably not appropriate, but I've found that setting the PlayStart to some absurdly high number also works, without the time calculation.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
aljachimiak
Visitor

Re: Simple HLS Question

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

I agree with this... Both that it works and that it does not seem like the best way to approach the problem.


If you have a livestream that is infinite, and you don't control the encoding for it, How can you reliably and safely move to the "most live" point in the hls stream?

Here is an example:

Using the RokuStream/RAF Tester with this appleHLS tester stream: https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8
Scenario one:
- Click the "Live" checkbox so it is checked
- Click "Go"
Observed result - Video plays at 29min 57sec.

Scenario two:
- Make the "Live" checkbox unchecked
- Click "Go"
Observed result - Video Plays at beginning (0 sec)

What is the "Roku Stream Tester" app doing to push the playhead to 29min 57 sec when "Live" is clicked?

Thanks!
0 Kudos