'How to create x264 RTSP server with OpenCV Python with GStreamer backend
My goal is to create a RTSP server using OpenCV Python using the GStreamer backend.
I have RGB images stored as OpenCV Mat
, and I would like to create a VideoWriter
which can write to a RTSP sink. The output video must be x264 encoded.
I believe this can be easily achieved using a GStreamer pipeline and providing the pipeline arguments to the VideoWriter
constructor and then later pushing frames to the VideoWriter, but the issue is I have no experience working with GStreamer and I find it very confusing.
The answers I have found on SO are incomplete, use specific hardware decoders (ex for NVIDIA Jetson), or are overly complex. I'd like to find a more generic solution which works on CPU.
Solution 1:[1]
I have created a project something related to your requirement sometime ago. This could be a kickstarter and customize it based on your need. I'm attaching my github repository link below.
Any issues related to the project can be raised in the github itself and doubts can be cleared here.
Solution 2:[2]
Check out the amazing VidGear library. There is an RTSP example in the link.
https://github.com/abhiTronix/vidgear/issues/228#issuecomment-1024904157
Edit: VidGear does not create RTSP server but lets you stream easily.
Solution 3:[3]
SimpleRTSPServer, Not in Python but very simple to run and use. Start the server in another terminal and write your outputs to there. The server easy to configure as well. You can capture read frames easily from another Python script or VLC.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | prabhakar-sivanesan |
Solution 2 | |
Solution 3 | alercelik |