samedi 1 août 2020

RTSP encoded Stream storage - Using OpenCV/C++

I hope all are doing great.

I am trying to do the RTSP video streaming display as well as storage. as shown in the following figure.

Working-flow-diagram The below Gstreamer pipeline is working fine for the following two task.

  1. Capture, decode and display.

  2. Capture & store the same stream into a file (without any decoding operation).

    gst-launch-1.0 -e rtspsrc location=rtsp://admin:888888@192.168.5.21:5001/udp/av0_0 ! rtph264depay ! h264parse ! tee name=t ! queue ! omxh264dec ! videoconvert ! queue ! autovideosink sync=false async=false t. ! queue ! mp4mux ! filesink location=out.mp4

Now, In order to process the frames, I have to perform the above similar task in the C++/OpenCV programming,

  1. Capture the RTSP encoded video stream, decode and process it.
  2. Capture & Store the incoming encoded RTSP video stream into the file without performing decoding operation on it using openCV/C++ programming.

The first task is doable using the OpenCV code shown below.

VideoCapture cap("rtspsrc location=rtsp://admin:888888@192.168.5.21:5001/udp/av0_0 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! appsink sync=false async=false",cv::CAP_GSTREAMER);

cap.read(img);
process(img);
  • Problem I have tried a couple of ways to do the second task but I could not able to do it.

I have tried the following code that can store the video stream in a file but not able to play stored output.mp4 file due to the wrong storage frames.

cv::VideoCapture cap ("-e rtspsrc location=rtsp://admin:888888@192.168.5.21:5001/udp/av0_0 ! rtph264depay ! h264parse ! tee name=t ! queue ! omxh264dec ! videoconvert ! queue ! appsink t. ! queue  ! filesink location=out.mp4");

cap.read(img);
process(img);
cv::imshow(img);

It would be greatly appreciated if anyone can guide me to do the second task (capture and store the Input encoded stream to a file).

Aucun commentaire:

Enregistrer un commentaire