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

Re: How to stream http stream?

Thanks so much for the help, I would be willing to try the tmp thing however it seems far too difficult for me to do. How would you go about doing it? Does it take a lot of steps? Thanks
0 Kudos
EnTerr
Roku Guru

Re: How to stream http stream?

"renojim" wrote:
It looks like they're reusing file names in that playlist. The content of the files changes every minute. I don't know if that meets the HLS spec, but somehow I doubt it. I'm surprised VLC plays it. If you really, really wanted to play it on a Roku, I suppose you could process the playlist and download the segments to tmp: while renumbering the segments and recreating the playlist on tmp:, but it would be a lot of work fraught with potential problems. Is it really worth it? You'd probably have better luck trying to get the producer of the stream to fix his encoding.

On the other hand, if the playlist really is valid under the HLS spec, then I guess you've uncovered a bug on the Roku. Something tells me it wouldn't be a high priority to fix. 😄

First, let me disclaim i am talking out of my mule here, since i haven't used HLS before - all i did was open teh spec and searched for "cache" in it. Using said ninja skill, here is what i found:
"http://tools.ietf.org/html/draft-pantos-http-live-streaming-13" wrote:
3.4.6. EXT-X-ALLOW-CACHE

The EXT-X-ALLOW-CACHE tag indicates whether the client MAY or MUST NOT cache downloaded media segments for later replay. It MAY occur anywhere in a Media Playlist file; it MUST NOT occur more than once. The EXT-X-ALLOW-CACHE tag applies to all segments in the playlist. Its format is:

#EXT-X-ALLOW-CACHE:<YES|NO>

See Section 6.3.3 for more information on the EXT-X-ALLOW-CACHE tag.
...
6.3.3. Playing the Playlist file
...
If the Playlist file contains the EXT-X-ALLOW-CACHE tag and its value is NO, the client MUST NOT cache downloaded media segments after they have been played. Otherwise the client MAY cache downloaded media segments indefinitely for later replay.
So if there is "#EXT-X-ALLOW-CACHE: NO" in the M3U, client is required NOT to cache segments, even if they repeat. If there is no such line or it has different value but "NO" (that is any other string, including "YES", "NOPE", "NEVER", "3.141592"!), the client is free to do whatever the heck they see fit - cache them or not cache them - and they will be spec compliant.

Now looking at our m3u,
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOWCACHE:1
#EXT-X-TARGETDURATION:10
it says "#EXT-X-ALLOWCACHE:1", which means exactly nothing. It should be saying NO there.

PS. even the name is misspelled there, EXT-X-ALLOWCACHE instead of EXT-X-ALLOW-CACHE ! That file is chock-full of errors. Can't blame RokuCo for the behavior, it would be bending over backwards.
0 Kudos
httpslash
Visitor

Re: How to stream http stream?

hi, thanks for the reply, i just download the m3u8 changed the allowcache to <NO>, added the link before the segments to make it play and then uploaded it to dropbox to point the roku to it. It still repeats :(, could it be because i used dropbox? Damn i tried everything, what makes it worse it that vlc plays it fine so i feel that there must be a way to make it play...
0 Kudos
EnTerr
Roku Guru

Re: How to stream http stream?

"httpslash" wrote:
Thanks so much for the help, I would be willing to try the tmp thing however it seems far too difficult for me to do. How would you go about doing it? Does it take a lot of steps? Thanks

Dang it, i got myself too involved here. Try something like this and then ask it to play the local m3u3?
    xfer = createObject("roURLTransfer")
xfer.setURL("http://stream0.latvdefrance.com/live/tf1.m3u8")
m3u = xfer.getToString()
tmp_m3u = ""
for each line in m3u.tokenize(chr(10)):
if left(line, 1) <> "#":
line = "http://stream0.latvdefrance.com/live/" + line
else if left(lines, 18) = "#EXT-X-ALLOWCACHE:":
line = "#EXT-X-ALLOW-CACHE:NO"
end if
tmp_m3u = tmp_m3u + chr(10) + line
end for
WriteAsciiFile("tmp:/tf1.m3u8", tmp_m3u)
0 Kudos
httpslash
Visitor

Re: How to stream http stream?

Hi thanks for taking the time to help. I really appreciate it. I am very new to roku, where would I paste your code? I'm using simple video player...?

EDIT: I pasted it in appmain.brs in simplevideoplayer, all i get is a loading... screen. Did i do it worng?
0 Kudos
belltown
Roku Guru

Re: How to stream http stream?

"renojim" wrote:
Um... there's only 6 segments in that file that just repeat over and over again. It's no wonder it repeats after a minute. I'm not sure it's even "legal" to repeat segments within the m3u8 playlist file.

I'm not sure it's illegal, although it does seem rather strange to keep repeating the same sequence numbers without removing files that previously used those same sequence numbers. The key point for this to work is that the client would need to read the playlist file starting near the end (not less than 3 target durations from the end of the playlist file I believe the spec says). For a "live" playlist I'd think you'd want to start as close to the end as you can safely do so anyway. I'd be curious to know whether the Roku player agrees, or whether it just starts reading from the start of the file no matter what, no matter how long the playlist file is. If I were a Roku person, it's something I'd be looking into. I don't think the spec requires that you have to delete segment Urls from the playlist file at any specific intervals. In the case of this stream, it doesn't look like the server is deleting anything from the file, just adding to the end, so even if the segment files were uniquely numbered, you wouldn't really have a "live" stream, rather a "delayed" stream, delayed by the total length of the playlist file. I wouldn't think that would be desirable behavior. If it were me implementing an HLS client, I'd start reading from closer to the end of the file.

"httpslash" wrote:
Hi thanks for taking the time to help. I really appreciate it. I am very new to roku, where would I paste your code? I'm using simple video player...?

EDIT: I pasted it in appmain.brs in simplevideoplayer, all i get is a loading... screen. Did i do it worng?


I wouldn't bother. It won't work, due to the way HLS operates. The m3u8 playlist file is updated every few seconds as new media segment files are added. It's not a "static" playlist file. Even if you could download it from the server every few seconds, create a new version of the file and write it out to a "tmp" file, I don't know whether the roVideoPlayer would be able to handle a local file as a stream Url, and even if it did, you'd have to do something about the fact that the segment files it references aren't local, but served from a remote url. I think you're out of luck, unfortunately.
0 Kudos
httpslash
Visitor

Re: How to stream http stream?

Thanks for the reply belltown, I have officially given up.
0 Kudos
EnTerr
Roku Guru

Re: How to stream http stream?

"httpslash" wrote:
hi, thanks for the reply, i just download the m3u8 changed the allowcache to <NO>, added the link before the segments to make it play and then uploaded it to dropbox to point the roku to it. It still repeats :(, could it be because i used dropbox? <Force equals mass times acceleration> i tried everything, what makes it worse it that vlc plays it fine so i feel that there must be a way to make it play...

It could be because they used the wrong header "EXT-X-ALLOWCACHE" instead of "EXT-X-ALLOW-CACHE:NO" - see my P.S. above.
0 Kudos
EnTerr
Roku Guru

Re: How to stream http stream?

"belltown" wrote:
I wouldn't bother. It won't work, due to the way HLS operates. The m3u8 playlist file is updated every few seconds as new media segment files are added. It's not a "static" playlist file. Even if you could download it from the server every few seconds, create a new version of the file and write it out to a "tmp" file, I don't know whether the roVideoPlayer would be able to handle a local file as a stream Url, and even if it did, you'd have to do something about the fact that the segment files it references aren't local, but served from a remote url. I think you're out of luck, unfortunately.

Hmm. Why are you so sure?
Video segments can be local, relative or full URLs:
"https://en.wikipedia.org/wiki/M3U#File_format" wrote:

Each entry ... can be any one of the following:
  • an absolute local pathname; e.g., C:\My Music\Heavysets.mp3

  • a local pathname relative to the M3U file location; e.g. Heavysets.mp3

  • a URL.

I have doubts about your previous paragraph too, where you say a player should start at the end of the m3u - rather seem to me that since a sliding window is used for live streaming, it is server's job to update the m3u promptly so that new clients hopping in are on the current segment. But that doesn't even matter in this case - as long as player keeps playing the 6 segments (each ~10sec) without caching - even if it started at the wrong # segment, the worst that can happen is delay from live of 5x10 = 50sec
0 Kudos
httpslash
Visitor

Re: How to stream http stream?

That's very interesting. I'm gonna try this as soon as I get home. Could it also be that vlc doesn't allow by default and that's why it doesn't repeat?
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.