Search code examples
pythonvideovideo-streamingpyglet

How to play video stream using pyglet? (mpeg-ts over http or rtmp h.264 codec)


I want to make software for displaying PIP(Picture in Picture) of 2 video streams. How can i know, pyglet allows play video only from file source.

May be i decide to use wrong lib (pyglet), please, advice what lib is bettor for my goals.

I'm also will be appreciated if you advice some books or articles connected with generating video streams.

Thank you!


Solution

  • Pyglet is fully capable of playing video, however, as you said, I do not think it is capable of streaming video. A much more popular library for this kind of program would be GStreamer. It offers much more functionality, and it can be extended with plugins. Here is a Wikipedia page for it, and here is the official website. If you look at the features page, you will see this:

    • container formats: asf, avi, 3gp/mp4/mov, flv, mpeg-ps/ts, mkv/webm, mxf, ogg
    • streaming: http, mms, rtsp
    • codecs: FFmpeg, various codec libraries, 3rd party codec packs
    • metadata: native container formats with a common mapping between them
    • video: various colorspaces, support for progressive and interlaced video
    • audio: integer and float audio in various bit depths and multichannel configurations

    So, it seems perfect for what you want to do (The bold bullet points are the ones I thought would interest you most).

    Luckily GStreamer has bindings for Python.

    Another library I have found, which you could use for the encoding part and all under-the-hood part is PyMedia. Maybe that would be something of interest too. However note that you do not need to use it as GStreamer can do everything that PyMedia can. I just put it in, incase you wanted to take a look at it, for future use perhaps.

    Good luck.