RTSP stream with openCV: Missing installation?

I would like to stream video to rtsp from opencv in python.

There are a lot of threads in here that mentioned about it like these links

but the problem is, when the code run to

if not out.isOpened() :
    print("Writer failed")
    exit()
print('Writer opened')

This would cause “Writer failed” error. So I think I might miss some installation somewhere? There is not many information on this so if anyone could give some guide, it would be very helpful.

FYI: Here is my code run on Jetson Nano that cause the error above

import cv2
import os
import numpy as np

cap = cv2.VideoCapture(RTSP_URL, cv2.CAP_FFMPEG)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(cap.get(cv2.CAP_PROP_FPS))

gst_out = "appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 " \
             " ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=127.0.0.1 port=5000"

out = cv2.VideoWriter(gst_out,cv2.CAP_GSTREAMER,0, float(fps), (int(width), int(height)), True)

print('Writer opened')
if not cap.isOpened():
    print('Cannot open RTSP stream')
    exit(-1)

while True:
    _, frame = cap.read()
    out.write(frame)

    if cv2.waitKey(1) == 27:
        break

cap.release()
cv2.destroyAllWindows()
"""

Also, I installed GStreamer following this website
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/accelerated_gstreamer.html#wwpID0E0R40HA

But same error occurs

Hi,
Please check if you can run the sample and see video preview:
Doesn't work nvv4l2decoder for decoding RTSP in gstreamer + opencv - #3 by DaneLLL

If yes, may try to apply the string in cv2.VideoCapture() to
Displaying to the screen with OpenCV and GStreamer - #9 by DaneLLL

Hi, I tried using code on the first link but it failed.
I even tried it using my local PC (windows) and it also failed, but using VLC can open the link to

rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

My environment is Python 3.6, Opencv 4.2.0 so I changed my code a little bit although it still failed

cap = cv2.VideoCapture(
        "rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! "
        "nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink ", cv2.CAP_FFMPEG)

Hi,
cv2.CAP_FFMPEG looks not required. Please remove it from cv2.VideoCapture() and try again.

You may also try gst-launch-1.0 command with fakesink to make sure the gstreamer command is good:

$ gst-launch-1.0 rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! fakesink

Hi, not having cv2,CAP_FFMPEG will give this error

OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink  in function 'cv::icvExtractPattern'

And the command line with gst-launch-1.0 gives error:

-bash: syntax error near unexpected token `('

I checked my installation with this command

$ gst-inspect-1.0 --version
gst-inspect-1.0 version 1.8.0
GStreamer 1.8.0

Not sure if this is enough to verify that it is good or not though

Okay, so I removed (string) part from your code and now it gives this error

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.155: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideosink.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideosink.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.156: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvivafilter.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvivafilter.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.156: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnveglglessink.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnveglglessink.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.157: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstomx.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.157: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvdrmvideosink.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvdrmvideosink.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.157: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvidconv.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvidconv.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.158: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvtee.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvtee.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.158: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvv4l2camerasrc.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvv4l2camerasrc.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.159: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.159: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvegltransform.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvegltransform.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.159: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnveglstreamsrc.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnveglstreamsrc.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.159: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideosinks.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideosinks.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.160: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.160: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvjpeg.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvjpeg.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.160: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideocuda.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideocuda.so: file too short

(gst-plugin-scanner:264): GStreamer-WARNING **: 18:47:26.161: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvcompositor.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvcompositor.so: file too short

which is weird so I check with ldconfig and it gives this error

 ldconfig
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libv4lconvert.so.0.0.999999 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libv4l2.so.0.0.999999 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_calib3d.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_flann.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_core.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_gapi.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_dnn.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_features2d.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_ml.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_dnn.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_photo.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_stitching.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_highgui.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_gapi.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_video.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_objdetect.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_videoio.so.4.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_imgproc.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_highgui.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_photo.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_flann.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_features2d.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libgstnvivameta.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_gapi.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_core.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libnvsample_cudaprocess.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_ml.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_stitching.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_videoio.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_dnn.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_calib3d.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_video.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libgstnvegl-1.0.so.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libgstnvexifmeta.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/libopencv_objdetect.so.4.1.1 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvdecode2eglimage.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvexif.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvofsdk.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvtracebuf.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvapputil.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcuvidv4l2.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvid_mapper.so.1.0.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvodm_imager.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvavp.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvid_mapper.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnveglstream_camconsumer.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcam_imageencoder.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurface.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcameratools.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmm.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcapture.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libtegrav4l2.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4l2_nvcuvidvideocodec.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvtvmr.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurftransform.so.1.0.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvtestresults.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmm_contentpipe.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvomxilclient.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmmlite_utils.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcamv4l2.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvargus.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvargus_socketserver.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvtnr.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4l2_nvvideocodec.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnveventlib.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvomx.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmm_parser.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmmlite_video.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnveglstreamproducer.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvscf.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvosd.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4l2.so.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvargus_socketclient.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurftransform.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmm_utils.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4l2_nvvidconv.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvdsbufferpool.so.1.0.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvbufsurface.so.1.0.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvv4lconvert.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcamlog.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvcamerautils.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvv4l2.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmmlite_image.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4l2_nvargus.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libv4lconvert.so.0 is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvparser.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvmmlite.so is empty, not checked.
/sbin/ldconfig.real: File /usr/lib/aarch64-linux-gnu/tegra/libnvdsbufferpool.so is empty, not checked.

Seems like the build is broken somehow?

I followed instruction here though (although I did it in docker)

Hi,
Please check if you incude this file in docker:

/etc/nvidia-container-runtime/host-files-for-container.d/l4t.csv

Seems like it is missing so you are not able to see the gstreamer libs.

Hi, it seems like there is no such file you mentioned in the docker so I tried adding --runtime nvidia but it shows following error

docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: driver error: failed to process request: unknown.

Hi,
If you have another Jetson device, we would suggest set up the device with SDKManager as a comparison. The samples should work well on default release. Setting up a working device should help you do further investigation.

Hi, I reinstalled the whole SDK package and now it works properly. I can fetch steam from my webcam and save to file via opencv (with gstreamer backend), however I want to open the video stream via RTSP but I think I am missing something.


import cv2
import os
import numpy as np
RTSP_URL = "rtsp://admin@192.168.100.100:554/cam/realmonitor?channel=1&subtype=0"

cap = cv2.VideoCapture(RTSP_URL, cv2.CAP_FFMPEG)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(cap.get(cv2.CAP_PROP_FPS))


gst_out = "appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 " \
             " ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=rtsp://127.0.0.1 port=8554"

out = cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, float(30), (int(width), int(height)))
if not out.isOpened() :
    print("Writer failed")
    exit()
print('Writer opened')
if not cap.isOpened():
    print('Cannot open RTSP stream')
    exit(-1)

count = 0

while True:
    _, frame = cap.read()
    out.write(frame)
out.release()

Any idea on how to fix this? I am pretty sure it has to be on this line

gst_out = "appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 " \
             " ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=rtsp://127.0.0.1 port=8554"

Hi,
We have tried to set up UDP and don’t have much experience about setting up RTSP. This would need other users to share experience.

Have searched online and this may help:
How to create x264 RTSP server with OpenCV Python with GStreamer backend - Stack Overflow