2

I'm trying to add HLS playback to a Python application. Currently, the most appropriate path to go down seems to be to use LibVLC and its Python bindings, as its the only multimedia library I've found for Python which can play MPEG transport streams out of the box (or at all). I'm open to other suggestions, though.

However, I also need my application to handle the fetching of the MPEG TS chunks from the HLS manifest itself, in order to set an appropriate user agent, manage proxy settings and store cookies between HTTP requests. Therefore, I have a thread downloading HLS chunks and adding them to a queue, which then feeds them into a BytesIO instance. I can easily enough save that instance to disk to emulate download functionality, but my question is, how can I feed the data from a BytesIO stream into LibVLC in order to play the stream in realtime?

I've tried using ctypes along with libvlc_media_new_callbacks (see my previous question here), but didn't get very far. I've also tried passing file descriptors of temporary files or pipes created using os.pipe, but VLC doesn't seem to be able to inherit and access these. If I save each chunk to its own temporary file and then queue them up in VLC, there is a gap in playback between each one. So I'm a bit stuck.

Any help would be very much appreciated!

James Scholes
  • 7,686
  • 3
  • 19
  • 20
  • Did you look at the media callbacks, i.e. libvlc_media_new_callbacks() - do your Python bindings support that? – caprica Mar 29 '16 at 08:29
  • Apparently they do - I linked to some code in a previous question in which I tried to use them without success. Admittedly I'm a bit like a fish out of water at the moment when it comes to ctypes and callbacks. – James Scholes Mar 29 '16 at 12:36

0 Answers0