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: 
ionatan
Roku Guru

HLS auto-switch

Would this work on a Roku Channel? Is working auto-switch with hls? Thanks!
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://server...../streamSD/playlist.m3u8</streamUrl>
</media>
<media>
<streamQuality>HD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://server...../streamHD/playlist.m3u8</streamUrl>
</media>
0 Kudos
20 REPLIES 20
RokuJoel
Binge Watcher

Re: HLS auto-switch

You would have to have something to parse it like:


if xml.parse(data)
videos=[]
for each object in xml.media
video={}
video.streamquality=[object.streamquality.gettext()]
video.streambitrate=[object.streambitrate.gettext().toint()]
video.streamurl=[object.streamurl.gettext]
videos.push(video)
end for
end if
video.SwitchingStrategy="full-adaptation"


and then feed that into your video playback function. But you should ideally have more data than just the videos, such as title, shortdescriptionLine1 and thumbnail images.

also, you need to check the device mode - if SDTV mode you would override the streamQuality with ["SD"] or playback will fail in SDTV mode.

- Joel
0 Kudos
RokuMarkn
Visitor

Re: HLS auto-switch

Actually for HLS, you should NOT specify multiple URLs. You should put the URLs for the different streams in the top-level m3u8 as specified by the HLS spec, and pass that one URL to the video player. This allows the player to dynamically switch bitrates.

--Mark
0 Kudos
ionatan
Roku Guru

Re: HLS auto-switch

Thanks!
0 Kudos
videodev
Visitor

Re: HLS auto-switch

Hello,

I am new to ROKU and using SampleVideoPlayer code to test my HLS streams. Even though, I have 6 different bit rates in my playlist.m3u8 file, ROKU picks the low quality stream and is not switching to high bit rate. I have enough internet bandwidth to use high quality stream.

Below is the section of code, which loads the streams from XML file:


e = curShow.media[0]
if e <> invalid then
item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
endif



Below is the XML for an item:

<item sdImg="http://xxxzzz.com/images/gh.png" hdImg="http://xxxzzz.com/images/gh.png">
<title>My Test Stream 2</title>
<contentId>10053</contentId>
<contentType>Movies</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>hls</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>0</streamBitrate>
<streamUrl>http://yyyzzz.com/playlist.m3u8</streamUrl>
</media>
<synopsis></synopsis>
<subtitleUrl></subtitleUrl>
<genres></genres>
<runtime>9600</runtime>
<hdBifUrl></hdBifUrl>
</item>


And below is the streams in playlist.m3u8 file:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=200000
http://yyyzzz.com/mp4:n_150k.mp4/playlist.m3u8?wowzasessionid=1937835477
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=400000
http://yyyzzz.com/mp4:n_300k.mp4/playlist.m3u8?wowzasessionid=1937835477
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=600000
http://yyyzzz.com/mp4:n_500k.mp4/playlist.m3u8?wowzasessionid=1937835477
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1000000
http://yyyzzz.com/mp4:n_800k.mp4/playlist.m3u8?wowzasessionid=1937835477
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1500000
http://yyyzzz.com/mp4:n_1200k.mp4/playlist.m3u8?wowzasessionid=1937835477
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2300000
http://yyyzzz.com/mp4:n_1800k.mp4/playlist.m3u8?wowzasessionid=1937835477


Any suggestions?

Thank you!
0 Kudos
TheEndless
Channel Surfer

Re: HLS auto-switch

Make sure you are setting the SwitchingStrategy value. A bug was introduced a few firmwares ago that would prevent HLS from switching to a higher bitrate if the SwitchingStrategy wasn't set. I don't know if that bug was ever fixed, but it's best to always set that value.
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
videodev
Visitor

Re: HLS auto-switch

Thank you for quick reply!

I will add that code and will test again!
0 Kudos
videodev
Visitor

Re: HLS auto-switch

"TheEndless" wrote:
Make sure you are setting the SwitchingStrategy value. A bug was introduced a few firmwares ago that would prevent HLS from switching to a higher bitrate if the SwitchingStrategy wasn't set. I don't know if that bug was ever fixed, but it's best to always set that value.


Thank you. It worked. I am using SwitchingStrategy as "full-adaptation".

Another question - As I mentioned above, I am using HLS streams from Wowza server, which has 6 variants from 150k to 3600k. I read in the documentation that, the dots/HD symbol is not displayed, if the stream is HLS. Is there any way to display HD if any of the variant is of HD quality?

I am using "0" as StreamBitrates in XML.

Any other suggestions for quick switching/buffering/scrubbling?

Thank you!
0 Kudos
RokuJoel
Binge Watcher

Re: HLS auto-switch

If you set HDBranded=true the HD logo should show.

- Joel
0 Kudos
danesor12
Visitor

Re: HLS auto-switch

Hi Joel,

Do you have a simple live streaming zip, an example which I can build on for live streaming studies? Similar to simple video player?
Sometimes, solutions have a way of staring in my face and I am not able to see it.
Appreciate all the help!

Thanks,
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.