I want to stream images processed by OpenCV
in RTSP.
My program image is as below.
1.capture avi/mp4 file using cv::VideoCapture
2.any processing
3.stream processed image in RTSP
cv::VideoCapture and processing did work.
But VideoWriter did not.
I use gstreamer pipeline as argument of VideoWriter, and gst-rtsp-server.
I concerned about fps.
In detail, input fps is 30fps.
But output fps is 3 fps I want to set.
So I implemented program that processes image per 10 frames.
Not sure you can easily/efficiently stream RTSP from opencv videoWriter.
Maybe building a recent gstreamer version with rtspsink could be a solution, but I can’t tell if this would really work out.
The easiest way would be to install v4l2loopback, then use a videowriter with gstreamer pipeline to v4l2sink into your v4l2loopback node (assuming here it created /dev/video1):
I tried the way using v4l2loopback. But my program failed.
v4l2loopback installation had probably succeeded.
[s]My program error message is as followings.
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to play) in CvVideoWriter_GStreamer::open,
file /home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1696
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:
/home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp:1696:
error: (-2) GStreamer: cannot put pipeline to play in function CvVideoWriter_GStreamer::open
Could not open the output video file for write
And pseudo cmd message is as followings.
$ gst-launch-1.0 videotestsrc ! videoconvert ! video/x-raw,format=BGRx ! identity drop-allocation=true ! v4l2sink
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Cannot identify device '/dev/video1'.
Additional debug info:
v4l2_calls.c(609): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
system error: No such file or directory
Setting pipeline to NULL ...
Freeing pipeline ...
[/s]
Above error occured by forgetting “sudo modprobe v4l2loopback”.
I have done test-launch and check client.
But no image displayed.
So I tested “gst-launch-1.0 v4l2src device=/video0 ! nvvidconv ! queue ! nvelgltransform ! nveglglessink”.
This displayed an image(not movie).
–02/18/2020
Finaly, I could stream and receive.
The error is caused by sync of sink is true.
Hello, I’m getting green display in VLC. Could you please help me? It is working when I use only test-launch to stream to vlc, but doesnt work with opencv
Not sure using v4l2loopback would be the best solution for later RTSP streaming.
You may try a videoWriter encoding into H264 and using RTP/UDP to localhost for test-launch:
opencv python example: