HLS streaming questions

I have been playing with this a bit and got it somewhat working.

one issue i am having is getting more than 3 .ts files to play.

is there something i should be doing server side to make it work?

i have not added the

#EXT-X-ENDLIST

so not sure why its not going on to #4, #5, #6

anyone else had this issue?

Are you using a third party HLS server or are you writing your own? If you’re writing your own, you must update the m3u8 file to contain the URLs of the transport streams as they become available. I assume you start with three ts files and then add more over time? You should also make sure you aren’t sending any cache control HTTP headers that might prevent a proxy from re-reading the updated m3u8 file.

–Mark

thanks mark

i was doing it on my own server actually…

what sort of calls does it make to my sever? and how often? if i set the duration at 10 is it every 10 seconds?

I have been googling for two days about this and not much info about what it does serverside.

EDIT: did some tests and seems it does check back every 10 seconds if duration is set at 10 seconds…

on to more tests

Section 6.3.4 of the HLS spec (http://tools.ietf.org/html/draft-pantos … reaming-03) describes how the client should reload the m3u8. It normally reloads every “target duration” seconds but if it finds that the m3u8 has not changed, it switches to a different interval as described by the spec.

–Mark

I’m not much of a php expert, but what is $_REQUEST[“count”] supposed to be? The client does not pass a “count” parameter to the m3u8 URL, if that’s what you’re expecting. It looks like you’re trying to simulate a live stream? So you should be adding new TS files based on time, not on anything that comes from the client.

–Mark

ahh sorry yes what is did was in the playlist

<html>
  <head>
    <title>iPhone Streams</title>
  </head>
  <body style="background-color:#FFFFFF; ">
    <center>
      <video controls width='250' height='250'>
        <source src="playlists/stream.php?count=0"/>
      </video>
    </center>
  </body>
</html>

is there a better way than what did in the code ? you mentioned time, i tried that too but my fear was

1.) more code working meant it could pause the stream
2.) maybe save some bandwith later on with a smaller file with less code

Mark…

I have been messing with this a bit today so and its working on VLC and stopped working on my iPhone and weird this is not even the stanadard .m3u8 is working on my iPhone anymore, its confusing.

But here is the finished code i made for a file, but even though the headers in the php file make it work as a .m3u8 Roku
wont recognize it it seems. i just did a test using the custom video example and add the .php file address. and it gives me this error. does it not like the .php extension here?

----- Running ------
 11, 0: startup progress
 11, 66: startup progress
 11, 132: startup progress
 9,-5: The format is not supported or the media is corrupt.
 16, 0: Playback completed.
 11, 0: end of playlist

here is the final code…

<?php      
header("Content-Type: application/x-mpegURL");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

$directory = "../streaming/";
$filecount = count(glob("" . $directory . "*.ts"));

$duration= $filecount * 10;

?>
#EXTM3U<?php echo "\r\n"?>
#EXT-X-MEDIA-SEQUENCE:1<?php echo "\r\n"?>
#EXT-X-TARGETDURATION:<?php echo $duration;?><?php echo "\r\n"?>
#EXT-X-ALLOW-CACHE:NO<?php echo "\r\n"?>
<?php 
$i=1;

while($i<=$filecount) {
   $sequence = $i;

$vid= "videoTest";
$video = "$vid$sequence.ts";

?>
#EXTINF:10,<?php echo " \r\n"?>
http://iptvmyway.com/roku/HLS/streaming/<?php echo $video;?><?php echo "\r\n"?>
<?php
$i++;

  
} // closes while loop
?>
#EXT-X-ENDLIST

One of the best ways to do a quick sanity check is download the m3u8 file in a browser or using a tool like curl or wget. You can then check the contents of the m3u8 you generated and see if it looks valid.

–Mark

it does turn valid thats what i do every time, i even echo it out to the browser by slashing out the header info …

look identical to one I hard code, no on have any luck or tried any of this yet? or is everyone still in contest hush mode? LOL

I have tested this over and over and its working on VLC but NOt the roku and now not on my iPhone either

here is the link to the .php file:
http://iptvmyway.com/roku/HLS/playlists/test.php

and a working m3u8 on Roku:
http://iptvmyway.com/roku/HLS/playlists/stream.m3u8

now strange thing is, that m3u8 will work on VLC and Roku but not my iPhone… keeps saying the movie can’t be played.

I have pasted the code above as well and you can see by the download it looks the same as the playlist file that is working.

“dynamitemedia” wrote:
I have tested this over and over and its working on VLC but NOt the roku and now not on my iPhone either

here is the link to the .php file:
http://iptvmyway.com/roku/HLS/playlists/test.php

and a working m3u8 on Roku:
http://iptvmyway.com/roku/HLS/playlists/stream.m3u8

now strange thing is, that m3u8 will work on VLC and Roku but not my iPhone… keeps saying the movie can’t be played.

I have pasted the code above as well and you can see by the download it looks the same as the playlist file that is working.

I’ve been playing with HLS and finally got in working on our channel/app. I see three issues – two (I think) with your code and one (potentially) with your testing. First, the testing – VLC does not really support HLS. It will play the files sequentially because it’s a playlist. So when it plays in VLC, what that means is – you have a valid playlist – but you may not have a valid HLS playlist. Secondly, looking at your PHP code – it looks like you’ve got TARGETDURATION set to the length of the entire stream.You should try to set it to 10 or something. When testing with the Roku, I had an issue with this – even though it should work when you’ve specified ENDLIST. Then the last potential issue I think I see is that you’re giving each segment the same title (a blank space) with> #EXTINF:10,. I would try giving them all unique titles. In my code, which I finally got working – they all have their sequence number as the title. That shouldn’t be a deal breaker because it’s just a title and doesn’t uniquely identify the segment – but you never know. Lastly, are you setting the content-type (mime) of the file being downloaded as “application/vnd.apple.mpegurl”?

very good tips Tom!

Let me play with this tomorrow, can i PM you if i have some questions?

The playlist titles are not used by the player. It’s fine for them to be empty.

–Mark

@ tom

could you show what info your passing as the header?

as far as mime type goes i have added

AddType application/vnd.apple.mpegurl .m3u8
AddType video/MP2T .ts

in my .htaccess … one ? i have about the .htaccess i have put this in the myserver.com/roku/HLS folder and inside the playlist folder i thought you only needed it on the HLS and not myserver.com/roku/HLS/playlist folder too.. is that true?

and have changed my header to this:

header("Content-Type: application/vnd.apple.mpegurl");
header("Cache-Control: no-cache");
header("Pragma: no-cache");

and i am still getting the media is not supported or corrupt error in roku

I also cleaned up that whitespace you mentioned.

if i am missing something or misunderstood could you maybe show your code that you got working?

I’m not using php or apache to serve up my streams. So I’m not sure what all you need to do on your end. Here’s a raw dump of an HLS playlist that works. Keep in mind that the IP address, etc. is would need to be changed to whatever your server is. I’m not using any of those other headers for cache control, etc.. Hope this helps.


HTTP/1.1 200 OK
Connection: close
Content-Length: 278
Content-Type: application/vnd.apple.mpegurl
Date: Thu, 07 Oct 2010 11:16:55 GMT
Server: Gabby Media Server

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1

#EXTINF:10,hls-44-00002.ts
http://127.0.0.1:42785/hls/hls-44-00002.ts
#EXTINF:10,hls-44-00003.ts
http://127.0.0.1:42785/hls/hls-44-00003.ts
#EXTINF:10,hls-44-00004.ts
http://127.0.0.1:42785/hls/hls-44-00004.ts

still nothing is working..

No one here is using apache or PHP to do a playlist?

So there is not another Developer here that is using apache to serve the stream?

Is there a reason? is it not a good idea or any help here would be help as i have spent 2 weeks on trying to get this to work, if its something that wont work please let me know.

I think you should explain exactly what you’re trying to do. Are you trying to stream a live stream? If so, what kind of hardware/software is producing the stream? Or are you trying to stream prerecorded (video on demand) content? If so, what format is that content in?

Generally developers who are using HLS use existing products like Wowza, Inlet, the Apple segmenter or the open source ioncannon segmenter to produce the playlist and TS files. The logic to produce the HLS files is nontrivial (as you’ve discovered) so there should be a good reason why you’d want to try to implement it yourself rather than using an existing solution.

–Mark

i have shown here and/or other posts that i have the .ts files its the playlist i am having issues with. i want to create a dynamic .m3u8 playlist.

it can be done with other playlists examples here:

http://djlab.com/2010/08/asxm3upls-on-demand-playlist-generator/comment-page-1/

http://www.palegroove.com/search/36

and i am trying to do the same with the .m3u8, i am sorry if i haven’t explained it better, at this time is only on existing videos. segmenting the videos is not an issue. Only making the playlist dynamic.

Are your streams live or VOD? In other words, are new TS files appearing dynamically while you’re playing? If you’re only playing VOD content, you just need to create the m3u8 file once and the task should be pretty easy. Retrotom gave you an example of an m3u8 file in this thread that you can use for comparison with yours. If you can’t find what’s wrong, post the contents of your m3u8 here (not the php code that generates it, but the m3u8 that is produced by that code).

–Mark