8.31.2010

HTTP Live Streaming Client

In keeping with the general trend of posting updates once a year, I've decided to make a little utility that might be useful to some people.

HTTP Live Streaming is a protocol developed by Apple and released as an IETF draft for the purpose of streaming multimedia (video and/or audio) over HTTP. The protocol is very simple, and relies on a constantly-changing .m3u playlist to control the playback.

Surprisingly, I didn't find any existing client software on the Web; the only extant clients seem to be iOS devices (iPhone, iPod touch, iPad) and Safari on Mac OS X (via QuickTime X).

So, I've hacked up a really simple Python client which calls up VLC and feeds it the stream. The client supports encryption (well, it does in theory; I have yet to find an in-the-wild stream to test this on), and should provide decent performance.

If you have any issues or feedback, please do reply in the comments!

Download the source code or a precompiled Windows executable (may require MSVCR71.dll).

The Windows executable assumes you have VLC installed to C:\Program Files\VideoLAN\VLC. If you have it installed elsewhere, you will need to edit the source code.

UPDATE [07/22/2012]: The source code has been updated to support HLS v3. Since I no longer own a Windows box, I cannot update the Windows exe. Therefore, if you run into issues with the Windows exe, I suggest you try the source code version.

Updated 05/25/2011: fixed links.
Updated 09/24/2011: fixed links.
Updated 07/22/2012: update to support HLS v3 playlists.

17 comments:

lorez77 said...

The file that should be hlsclient.exe is hlsclient.py and I dunno what to do with that kinda file

Robert Xiao said...

Fixed; sorry about the confusion!

Robert Xiao said...

I've updated the packages. Notable fixes: compatibility with several Internet streams, fixed stuttering or missing audio on many streams, fixed synchronization issues with some configurations.

lorez77 said...

Do you happen to know what's the url for the apple live streaming thing today?

Robert Xiao said...

http://qthttp.apple.com.edgesuite.net/1009qpeijrfn/sl.m3u8

Unknown said...

I downloaded the program and it works well! Thanks a lot. You said hlsclient.exe also supports encrypted HTTP live streaming. I tried it, but it didn't work? For example, hlsclient.exe needs to get a key somewhere in the web, but I guess it doesn't support it. Is there any way I can do it? Thank you!!

Hristo said...

Both links for the .exe and the source don't work. Please, can you fix the links?

Robert Xiao said...

Fixed; thanks for letting me know.

submergent said...

hey - your links seem to be down again... any chance on getting them fixed? i would love to get my hands on the source code here. thanks!

Little pig said...

link dead. Could you fix it?

Robert Xiao said...

Thanks for all your comments! I've uploaded the files to Google Docs, so they should hopefully have more permanence there.

@Yong-Joon: It supports encrypted streams if the stream's playlist file contains the encryption key URL. I've never personally encountered such a stream, so I coded that part of the player from the specification. If you have an example encrypted stream, I could use that to improve the decryption support.

Charlie Furlani said...

I'm getting the error:

Traceback (most recent call last):
File "hlsclient.py", line 261, in
File "hlsclient.py", line 214, in main
File "subprocess.pyo", line 594, in __init__
File "subprocess.pyo", line 822, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified

Any ideas?

Robert Xiao said...

@Charlie:

As per the last sentence:

"The Windows executable assumes you have VLC installed to C:\Program Files\VideoLAN\VLC. If you have it installed elsewhere, you will need to edit the source code."

You probably don't have VLC installed there; for example, it might be in C:\Program Files (x86)\VideoLAN\VLC instead. You should either copy the files over or edit the source code.

beewee!! said...

1 test1.m3u8 program 1 bitrate 0.29 kbps
Selection? 1
Traceback (most recent call last):
File "hlsclient.py", line 261, in
File "hlsclient.py", line 224, in main
File "hlsclient.py", line 153, in handle_basic_m3u
TypeError: int argument required

do you know whats going on here ?

Robert Xiao said...

@beewee!!: I made a typo. Please change the text

[warn] file version %d
to
[warn] file version %s

in hlsclient.py.

beewee!! said...

yes, there was one more tweak needed, some manifest files have #EXTINF:10.01
The script was expecting an integer. Another question, how does this work with encryption ? Also, can you put the google code link here. Thanks

Robert Xiao said...

@beewee!!: There's no Google Code link. The code may work with encrypted playlists, but I have not tested this extensively. Encryption keys are retrieved from a separate URI; you may have to add cookies or authentication parameters to the script to download such an external key URI.

I've updated the script. Please try it out and let me know if it works without requiring edits.