RTSP gstream simple receive downscale, then store in file

I can use following command to read an rtsp stream that is H264 encoded and save it to a file:

gst-launch-1.0 -ev rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp, media=video, encoding-name=H264 ! queue ! rtph264depay ! h264parse ! matroskamux ! filesink location=received_h264.mkv

Can anyone help me modify the command to downscale the video to a predefined resolution before saving the file? I’ve tried using videoscale element but couldn’t make it work.

Hi,
You would need to decode, downscale the resolution, and re-encode the content. Below is a sample command for downscale to 640x480.

gst-launch-1.0 -ev rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp, media=video, encoding-name=H264 ! queue ! rtph264depay ! h264parse ! nvv4l2decoder ! ! nvvidconv ! 'video/x-raw(memory:NVMM),width=640,height=480' ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=received_h264.mkv
1 Like

Thanks for the reply.

I tried the command (removed one extra ! ) but I get the following error:

WARNING: erroneous pipeline: could not link nvvconv0 to nvv4l2h264enc0, neither element can handle caps video/x-raw(memory:NVMM), format=(int)640, height=(int)480

The following command worked for me:

gst-launch-1.0 -ev rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp, media=video, encoding-name=H264 ! queue ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! ‘video/x-raw(memory:NVMM),width=640,height=480’ ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=received_h264.mkv

Any idea how I could execute the same command from a python app?

Hi,
For python + OpenCV, please refer to
Doesn't work nvv4l2decoder for decoding RTSP in gstreamer + opencv - #3 by DaneLLL
For only python, please take a look at
Nvv4l2decoder sometimes fails to negotiate with downstream after several pipeline re-launches - #16 by DaneLLL

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.