[mythtv-users] HTTP live stream and seeking in .25

George Nassas gnassas at mac.com
Tue Mar 6 05:10:06 UTC 2012


On 2012-03-05, at 4:29 PM, Ian Bishop wrote:

> I've been looking for specifications for a HTTP stream protocol, but
> haven't found anything that looks widely accepted enough to assume
> that's what has been implemented here.


I'm not an expert but I have noodled around with streams a little and can pass on what I know. MythTV implements http streaming as originated by Apple which you can read about in their developer library document titled "HTTP Live Streaming Overview". At this moment the document lives here & I believe nearby is a link to a PDF.

The big picture goes like this: a server (MythTV in this case) encodes a video as a series of short clips, say 10 seconds long, and supplies clients with an "m3u8" file url containing the names of the segments. You retrieve each segment in turn and play them back to back so it's seamless to the user. If the list is open ended then it's considered to be an in-progress event and you have to periodically requery the m3u8 url for the current list of segments. As you might guess you can calculate the total length of the video by multiplying the segment duration by the number of segments and you can seek by dividing your desired position by the segment duration to get the segment number and using the remainder as an offset into that clip.

In the previous paragraph I said "you" a few times but you personally don't have to get involved at such a low level. Software such VLC will take an url and do the grunt work. Or, in writing your own application you would embed a video widget supplied by your O/S and have it do the grotty stuff. I'm pretty sure you don't want to write your own widget, go with your OS's one. Typically a widget will take an URL and play it without further prodding but they also expose an api for you to query the current position, seek to a given offset, pause, resume, etc. Also, widgets supply an OSD so users can see where they're at and click arrows or a slider to move back and forth. Your job as a programmer then becomes slicing and dicing the list of media offered up by mythtv, initiating streaming transcodes, and handing off m3u8 urls to your embedded player.

That's a fairly breezy introduction but hopefully gets you oriented. It's really not very complicated but there are several moving parts and at first it's hard to tell where one ends and the other begins.

Assuming you're running a recent master you can get a decent education by kicking off a stream and examining the entrails. Start by defining a directory for the "Streaming" storage group (mythtv-setup -> Storage Directories) and then starting a stream. In that folder you'll find the expected m3u8 file but also an html file which shows how you might play a stream in a browser. An Android application would be conceptually similar. Aside from the video clips everything in that streaming directory will be text files so snoop and learn.

- George
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20120306/f07bc93a/attachment.html 


More information about the mythtv-users mailing list