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: 
railfan
Channel Surfer

HLS ABS Streaming how to.

Hi everyone,

I am trying to learn how to do Adaptive Streaming with my Video on Demand content and also our live content. I have a roku channel working with everything but the ABS stuff. I now own 3 roku boxes and our membership of over 500 about 10 - 20% is looking to get a box once we get the channel working.

If I could get some examples of how to make it work I would be able to figure it out.

Hope you can help me...

Mike
0 Kudos
18 REPLIES 18
RokuJoel
Binge Watcher

Re: HLS ABS Streaming how to.

There are two ways to do adaptive streaming on Roku.

With progressive mp4, you would have an array of media items each with its own bitrate, example:

episode={shortdescriptionline2: ""
shortdescriptionline1: "test 123"
contentid: "10014"
sdposterurl: "http://test.com/testSD.jpg"
description: "this is a test"
ishd: true
streamformat: "mp4"
contentquality: "HD"
length: 0
streamurls: ["http://test.com/test.mp4"
"http://test.com/test-3000kb.mp4"
"http://test.com/test-1500kb.mp4"
"http://test.com/test-800kb.mp4"]
streamqualities: ["HD"
"HD"
"HD"
"HD"]
streambitrates:[9000
3000
1500
800]
hdposterurl: "http://test.com/testHD.jpg"
title: "a test a test a test"
contenttype: "episode"
hdbranded: true}


for HLS streaming, you would have a single playlist file for the url in your media item (don't use more than one for HLS), example:

episode={shortdescriptionline2: ""
shortdescriptionline1: "test 123"
contentid: "10014"
sdposterurl: "http://test.com/testSD.jpg"
description: "this is a test"
ishd: true
streamformat: "hls"
contentquality: "HD"
length: 0
streamurls: ["http://myserver.com/playlists/multibitrate.m3u8"]
streamqualities: ["HD"]
streambitrates:[0]
hdposterurl: "http://test.com/testHD.jpg"
title: "a test a test a test"
contenttype: "episode"
switchingStrategy="full-adaptation"
hdbranded: true}


In both cases, the device will autoswitch between the bitrates, however with Progressive mp4 you will see "Loading" when it switches, vs HLS which you'll just see the quality of the video get better or worse depending on bandwidth.

You also need to take into account the current video setting of the device, and if the device is in SDTV mode, you need to set the various HD flags (ishd, qualities, quality, hdbranded etc) appropriately for progressive mp4 and streamqualities=["SD"] for HLS.

- Joel
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

Joel-

Thanks so much is this done in the xml file so each time I add to my VOD I don't have to push out another channel update.

My current XML is for a VOD File:

<item sdImg="http://www.railstream.biz/roku2/images/Roku-HD-LIVE.png"
hdImg="http://www.railstream.biz/roku2/images/Roku-HD-LIVE.png">
<title>NS and CSX AROUND OHIO VOLUME 1</title>
<contentId>10001</contentId>
<contentType>Live Railroad Cams</contentType>
<contentQuality>HD</contentQuality>
<streamFormat>HLS</streamFormat>
<media>
<streamQuality>HD</streamQuality>
<streamBitrate>4500</streamBitrate>
<streamUrl>http://streamingserver.site.com:1935/vod/smil:LIFORD_VOL1.smil/playlist.m3u8</streamUrl>
</media>
<synopsis>NS and CSX AROUND OHIO VOLUME 1</synopsis>
<genres></genres>
<runtime>57</runtime>
</item>


I know SMIL files are not to be used but it does play the first file in the list. I am still learning 🙂 so I hope you give me a brake 😉

When I use Sorenson Squeeze 9 I have it spit out based on the video files 1080p, 720p, 480p, 360p, 240p also at different datarates.

Thanks,

Mike
0 Kudos
RokuJoel
Binge Watcher

Re: HLS ABS Streaming how to.

There is no reason why you can't use a .smil file, just make sure you have the bitrates in the .smil organized correctly (I don't recall if this is highest to lowest or vice versa).

- Joel
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

Hi Joel-

Have them set to Highest to lowest. I did have it the other way and it would never change from the lowest to a higher resolution. I have 50MB/10MB connection to the net so I never saw it change yesterday. I can bottle neck it to see what happens, I just thought I had to do something else since I have been researching that Roku does not fully support smil files. Based on your statement that's not true if so then I am doing it correctly? The code you posted is that BS or XML?

I don't know if Roku does this but some other hardware companies I work with Crestron, AMX, Extron and others offer classes to learn there programming language and how to put it into real world applications. The SDK is nice but in a classroom you would be able to ask these questions and learn much faster how to set up the Roku boxes correctly. The Forum is great but I would pay $$$ for a class to better learn how to program the box. Just an idea...

Thanks for the help! I just ordered my third box so now I have them all for Roku 2's and Roku 3's to test our channel on prier to submitting it to be public. I am going to hook it to my Autopatch Analog Switcher and push it to my Crestron Touch Panels around my Model Railroad room so when I am working on the layout I can watch the roku box. My Roku 3 is hooked to my Crestron Digital Media system so we can have it in any room at any time or out at the Hot Tub 😄 Got to love being a system integrator !!!

I enjoy Roku and we are at this time only going to write a channel for this to be our only supported STB.

SMIL File the Roku is reading:

<smil>
<head>
</head>
<body>
<switch>
<video src="mp4:CHUCK_LIFORD_VOL005_4000Kb.mp4" height="720" system-bitrate="4900000" width="1280"/>
<video src="mp4:CHUCK_LIFORD_VOL005_2000Kb.mp4" height="480" system-bitrate="2000000" width="852"/>
<video src="mp4:CHUCK_LIFORD_VOL005_768Kb.mp4" height="360" system-bitrate="830000" width="640"/>
<video src="mp4:CHUCK_LIFORD_VOL005_360Kb.mp4" height="240" system-bitrate="540000" width="428"/>
</switch>
</body>
</smil>

I am not sure if I am doing something wrong but when I tell it its a HD video it does not show the "HD" as its loading the video for playback. Not a big deal just wondering if its something in my videowindow BS or in my XML file.

Thanks again for the help!!!!

-Mike
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

I think my problem is my video player is not setup to support what I want to do. I would like to go both Live / VOD streaming both will be HLS type streaming. I want to just edit the xml files as we add new content. With SMIL files ithe VOD does play but it just sits at the first video rate in the list. Any one got examples I could use???

Function showVideoScreen(episode As Object)

if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif

port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)

screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)

while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

End Function
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

I found this in another thread for the simple video window:

item.StreamFormat="mp4"
End If
If item.StreamFormat="hls"
item.SwitchingStrategy="full-adaptation"
End If


I put it in showfeed.brs and I am going to do some testing with it today. With HLS and ABS and 240p, 360p, 480p, 720p, 1080p all in the same m3u8 file does the roku box know when its in SD mode not to try to ABS to the 720p or 1080p or do I have to do seprate xml entries for each HD & SD? I just added HD,SD to my xml and I got it to show on my SD test bed setup. But the Balls still show when I set the stream quality to 0.

I am using the demo video player to build our channel off of.

Thanks,

Mike
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

The Roku box does not seam to get what it needs from the SMIL file or the wowza generated playlist.m3u8 when I set it lowest to highest it will not HLS ABS it just sits on the lowest stream rate.

So FYI HLS ABS with WOWZA smil files does not work or at least for me.

Mike
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

Some help please 🙂

Thankyou
0 Kudos
railfan
Channel Surfer

Re: HLS ABS Streaming how to.

This works with SMIL files now I just need to figure out what to change in the videoplayer SDK to get HLS ABS to work something in it is not allowing it to work.

sub main()
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = [0]

videoclip.StreamUrls = ["http://wowzastreamingserver.com:1935/vod/smil:yoursmilfile.smil/playlist.m3u8"]

di = CreateObject("roDeviceInfo")
if di.GetDisplayType() = "HDTV" then
videoclip.streamqualities=["HD"]
else
videoclip.streamqualities=["SD"]
end if

videoclip.StreamFormat = "hls"
videoclip.Title = "my awesome live stream"
videoclip.SubtitleUrl = ""
videoclip.switchingstrategy="full-adaptation"

video.SetContent(videoclip)
video.show()

lastSavedPos = 0
statusInterval = 10

while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
return
exit while
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 10000

end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
print "play failed: "; msg.GetMessage()
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while
end sub
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.