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: 
pebkac
Visitor

HLS Failover issues

Hey - hoping someone can show me what I'm doing wrong here....

I am publishing a stream from a single encoder at two bandwidths (384, 1500 - chunks in sync), and making each available via three edge nodes from the primary publishing point. Any of those play fine, and if I put all three node IPs in a muliple-A-record round robin DNS entry the Roku will pick one via DNS.

So I'm configuring my roVideoScreen like this:

video = CreateObject("roVideoScreen")
video.setMessagePort( CreateObject("roMessagePort") )
videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = [384,384,384,1500,1500,1500]
videoclip.StreamUrls = [args.LowA, args.LowB, args.LowC, args.HighA, args.HighB, args.HighC]
videoclip.StreamQualities = ["SD","SD","SD","HD","HD","HD"]
videoclip.StreamFormat = "hls"
videoclip.Title = args.title
videoclip.SwitchingStrategy="full-adaptation"
video.SetContent(videoclip)
video.show()

The URLs are the fully qualified URLs to the low and high bitrate streams on three different edge nodes in different cities.

1) When I start playing the stream, it seems to always pick HighC (high bandwidth, third option). When I turned off that server, I expected it to choose a different server, but instead it threw Event 11 (Message "Unspecified or invalid track path/url.invalid") showed "Checking Connection" on the TV, and returned to the springboard. If I try to restart the stream, it errors immediately because server "C" is down, and returns to the springboard. Doesn't attempt to try server A or B. I'm assuming there's something wrong with how I've configured this - can anyone shed any light?

1a) I've noticed that it always seems to pick the last URL on my list. Is that coincidence, random happening, or mis-coding? (If it's not random I would also need to implement a way to shuffle the order of the A/B/C URLs to ensure load balancing, so that I don't wind up with all my audience on the same server)

2) I also have a question about how video URL switching works; I've noticed that a client may have a slow route to an edge node in one city, but good speed from other edge nodes - all down to the routing and which internet path their ISP sends them to reach each edge node. So in some cases, switching to a lower bandwidth is a quick fix to keep video running, but switching back to a DIFFERENT high bandwidth server is possibly the best solution for the rest of the broadcast, rather than staying on low bandwidth for the duration.

eg:

Edge Node A: Standard bandwidth - too slow - Roku switches down
Edge Node X: Low bandwidth - plays great - Roku considers switching up
Edge Node B: Standard bandwidth - hey this works fine because it didn't choose "A" again

2a) Should the Roku do this automatically? (It doesn't seem to)

2b) Do we know that it won't choose City A when it changes back to high bandwidth again - or is there a chance it will - and fail again?

2c) Once it finds a URL that works nicely, will it stay with it - or randomly switch away to other URLs at the same bandwidth level when it requests subsequent chunks? It seems the way I have it so far, it isn't switching at all, even if the server goes offline (!) - so I'm not super concerned about this just yet 🙂

3) Or - Is there any way I can change the URL list / setting on the fly, WHILE it's playing? If so I could implement this logic while the Roku is playing - and make load balancing and internet route selections in BrightScript code myself based on bandwidth/buffer reports.

4) Is there any way to get in touch with Roku Engineering to get clarification on how the internals of the adaptive bitrate switching actually work - and how it makes its stream selections? - in particular - if there are multiple URLs at the same bitrate, what is the selection criteria?

To summarise the goals are:

- Pick another stream if the server is down
- Switch to low bandwidth if high isn't sustainable
- Try returning to a different server at the high bandwidth if one didn't work well previously

And what I have so far is:

- Roku tries to play the last URL in the list. if it's not available or becomes unavailable it quits unceremoniously.

Thanks for any tips!!
0 Kudos
2 REPLIES 2
RokuChris
Roku Employee
Roku Employee

Re: HLS Failover issues

When playing HLS content, the player expects exactly one stream URL pointing to a manifest that defines all the variants for that content. When you pass all the variants separately like you're doing, it will not adapt.
0 Kudos
pebkac
Visitor

Re: HLS Failover issues

Hi Chris

Thanks for the tip - I'll try that for sure as far as the bandwidth switching goes.

As far as switching to alternative servers - would I just list the full URLs of both servers in the manifest - so there are multiple options for each bitrate?

Can you shed any light on how the switching mechanism works when there are multiples at the same bitrate? Would it switch to a low bitrate option then try a different high-bitrate if all goes well for a chunk or two?

Thanks!
0 Kudos