RTSP Gstreamer Simple Recieve and Store in File

Hello Experts,

I would like to simply save the incoming RTSP streaming videos and saved as the MP4/MKV file. The objective is to benchmark and see whether H.264 or H.265 is better in the current setup.

Not further tested, but assuming your input stream is H264 encoded, you would try such gstreamer pipeline (adjust the URI for your case):

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

You would stop recording with Ctrl-C and would be able to playback on Jetson with:

gst-launch-1.0 -ev filesrc location=received_h264.mkv ! matroskademux ! decodebin ! nvvidconv ! xvimagesink

Hi @Honey_Patouceul

CC: @Honey_Patouceul @DaneLLL @Amycao @kayccc @WayneWWW @icornejo.a @AastaLLL

I would like to test it for both H.264 and H.265. I have an IP camera that supports RTSP streaming with various encodings.

How it works for H.265 ? Just replace H.264 to 265 is ok ?

Yes, if your cam is sending H265 encoded stream, just replacing H264 with H265 and h264 by h265 should work as well.

Hi @Honey_Patouceul

CC: @Honey_Patouceul @DaneLLL @Amycao @kayccc @WayneWWW @icornejo.a @AastaLLL

I tried the commands you specified.
No Luck, I inspected it with the TCP flow tool or application and the log is showing 401 Error in the log collected. But gstreamer reported Server Timeout.

But transaction successful when tried directly from cv2.VideoCapture() (opencv). Seems gstreamer client has trouble in passing RTSP authentication.

Any other way ?

You may try video playback:

gst-launch-1.0 uridecodebin uri='rtsp://_RTSP_URI_' ! nvoverlaysink

Check if you can see video preview to ensure the uri is valid.

Hi @DaneLLL

The URI works from ffmpeg but fails while using gstreamer. It looks very strange for me

You would need to figure out a working URI first. At least you have to successfully run the pipeline:

gst-launch-1.0 rtspsrc location='_rtsp_uri_' ! fakesink

One other thought: do you have any special character such as ‘%’ in your rtsp password (or login) ? This might explain the issue.

Hello @DaneLLL

Still URI loading is not working with gstreamer but it works with ffmpeg.

You may get more details with:

GST_DEBUG=rtspsrc:5   gst-launch-1.0 rtspsrc ...

Hi @Honey_Patouceul

Is there any reason why gstreamer accelerated with NVIDIA is not able to resolve the URL whereas from PC it happens ?

If you can play from other Linux hosts but not from Jetson, there should be a reason. This is what I’m trying to help to figure out.
Are you able to read other RTSP streams from your Jetson such as this one ?

gst-launch-1.0 rtspsrc location=rtspt://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! fakesink

Also, try increasing rtspsrc log level as in my previous post, get the ouput into a txt file and upload it here.

Hi @Honey_Patouceul

Oh finally issue resolved with the command.

 sudo apt-get remove gstreamer1.0-plugins-ugly

Seems the Gstreamer RTSP source is sending some Header which the Camera doesn’t like and gives denial of service. Now it works after removing the above plugin. Thanks for the Help Guyz @Honey_Patouceul @DaneLLL


Thanks bro, it’s work for me, the dahua ip camera, jetson Xavier NX and nano, gstreamer python binding.