python-3.xstreamingmatroska

Streaming video player


I need to make a video server-client, in which the server sends the video data in chunks, and the client has to receive them and show them. Unlike any of the projects I've ever made, I don't have a main structure for it in my mind, because I can't find an api or module for displaying the video which could be separated in chunks. All the files that are to be displayed are matroska .mkv. I've been searching but all I could find was kivy, which does offer video displaying but it requires the whole video, and gstreamer which has the same drawback. Can anyone point me a module I can rely on for video displaying?

Thanks in advance


Solution

  • Unless you are making this yourself for learning purpose then it will be much easier to build on existing work if possible as video streaming and playback is complicated.

    For streaming a file in 'chunks' you can simply server it as a static resource from a HTTP server that supports byte range requests - this allows the client to request a range of bytes rather than the whole video file, so it can download it chunk by chunk.

    Using this along with the regular HTML5 video tag in a browser will work for most video formats - the browser intelligence behind the video tag will already know to check if the server supports byte range requests and if it does to use them.

    If you want a more sophisticated video streaming, with Adaptive Bit Rate for example to request different bit rate chunks depending on the network conditions, then you may want to look at a special purpose Streaming Server such as Streamer or VideoLan:

    On the client side the open source dash.js reference app will give you a good example of using the HTML5 Media Source Extension to allow the client request the chunks and then build them back into the video to play (this uses MPEG DASH as the streaming protocol, which is becoming an industry standard).

    If you do want to go the DASH route then there is a good blog post at the link below which works through the steps to prepare a mkv file for streaming this way using the open source MP4Box tool: