Gstreamer RTSP server setup

Hello,

I am trying to setup an RTSP stream using gstreamer, except that I can’t get it to work, at all.
To begin with, I tried running the command shown here to start a stream.
gst-launch-1.0 videotestsrc ! omxh265enc ! rtph265pay name=pay0 pt=96

I used VLC player to check the stream on the local address: rtsp://127.0.0.1:8554

I also tried modifying my own command to just capture the footage from the camera. This works fine.
gst-launch-1.0 -v v4l2src device=/dev/video1 ! image/jpeg, width=1280, height=960, framerate=30/1 ! jpegdec ! videoconvert ! omxh264enc ! flvmux ! filesink location=videostream.flv

The command for streaming:
gst-launch-1.0 v4l2src device=/dev/video1 ! image/jpeg, width=1280, height=960, framerate=30/1 ! jpegdec ! videoconvert ! omxh265enc ! rtph265pay name=pay0 pt=96

The part of actually setting the video as a stream just doesn’t work for some reason. Am I missing something?

The pipeline you’re trying is incomplete. The string is intended to be passed to test-launch, which is an example of gst-rtsp-server. It would launch a rtsp server serving the output of the passed pipeline:

test-launch "videotestsrc ! nvvidconv ! omxh265enc ! rtph265pay name=pay0 pt=96 "

Hi @FPSUsername,

As @Honey_Patouceul stated that string is an incomplete pipeline. I would recommend giving a try to RidgeRun’s RTSP sink gstreamer element which permits high performance streaming to multiple computers using the RTSP / RTP protocols.

For example you would simply do:

gst-launch-1.0 videotestsrc ! x265enc option-string="keyint=30:min-keyint=30:repeat-headers=1" ! video/x-h265, mapping=/stream1 ! rtspsink service=5000

More information at: GStreamer rtspsink element | GStreamer | RidgeRun

Hi,
There are several posts about RTSP. FYR.

Sorry for not mentioning it. I did clone the RTSP-server repository, checked out branch v1.14 and did exactly what was posted here. This didn’t work for me (it started, but I couldn’t connect to the stream).

Hi,
If you run

./test-launch "videotestsrc ! omxh265enc ! rtph265pay name=pay0 pt=96"

The server should up and ready. Somehow in your post you run it through gst-launch-1.0. This is wrong.

gst-launch-1.0 videotestsrc ! omxh265enc ! rtph265pay name=pay0 pt=96

I can’t explain the behavior, I tested the top command from DaneLLL previously and that didn’t work. Now all of a sudden it works. (I was using the test-launch script)

Edit:
I rebooted the TX2 to try again and it seems that it doesn’t work reliably. I rebooted once more afterwards and it works.

Problem now is that the camera doesn’t start up with this command:
./test-launch "v4l2src device=/dev/video1 ! image/jpeg, width=1280, height=960, framerate=30/1 ! jpegdec ! omxh265enc ! rtph265pay name=pay0 pt=96"

For further advice, what is the output of the following command ?

v4l2-ctl -d /dev/video1 --list-formats-ext

Depending on your camera, you may have to use plugin jpegparse. Does this work ?

gst-launch-1.0 v4l2src device=/dev/video1 ! image/jpeg, width=1280, height=960, framerate=30/1, format=MJPG ! jpegparse ! jpegdec ! videoconvert ! xvimagesink

This is the output. Ofcourse I’m going with the MJPG output because of the framerates.

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : Motion-JPEG
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1024x768
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x960
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1600x1200
                        Interval: Discrete 0.067s (15.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.067s (15.000 fps)
                Size: Discrete 2048x1536
                        Interval: Discrete 0.067s (15.000 fps)
                Size: Discrete 2592x1944
                        Interval: Discrete 0.067s (15.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1024x768
                        Interval: Discrete 0.133s (7.500 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.133s (7.500 fps)
                Size: Discrete 1280x960
                        Interval: Discrete 0.133s (7.500 fps)
                Size: Discrete 1600x1200
                        Interval: Discrete 0.333s (3.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.333s (3.000 fps)
                Size: Discrete 2048x1536
                        Interval: Discrete 0.333s (3.000 fps)
                Size: Discrete 2592x1944
                        Interval: Discrete 0.333s (3.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)

My test code to save as a file works fine:
gst-launch-1.0 -v v4l2src device=/dev/video1 ! image/jpeg, width=1280, height=960, framerate=30/1 ! jpegdec ! videoconvert ! omxh264enc ! flvmux ! filesink location=Videostream.flv

From your command it tells me:

Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)

Hi,
The command of using E-Con See3CAM CU135 is

It should work by modifying width, height to fit your USB camera.

Thanks, I’ll take a look at it. Currently I’m running Jetpack 4.3, do I need to apply the patch?

I have the DELOCK 96368 USB camera

Hi,

No. It is fixed in Jetpack 4.3

Okay, so now that’s that, I have the last issue where the camera doesn’t start up when running this command:
./test-launch --gst-debug-level 3 "v4l2src device=/dev/video0 io-mode=2 ! image/jpeg, width=1280, height=960, framerate=30/1, format=MJPG ! jpegparse ! jpegdec ! videoconvert ! omxh264enc ! rtph264pay name=pay0 pt=96"

The command should be correct, yet the LED on the camera board doesn’t light up. The camera works (tested with Cheese and gst-launch-1.0)

This is the error I get when connecting to the RTSP server:

0:00:10.475215965  9027   0x558921a590 ERROR             rtspclient rtsp-client.c:2910:handle_describe_request: client 0x558930e110: no media
0:00:17.562239665  9027   0x7f94005d90 WARN                    v4l2 v4l2_calls.c:616:gst_v4l2_open:<v4l2src1> error: This isn't a device '/dev/video0'.

Rerunning this command: v4l2-ctl -d /dev/video0 --list-formats-ext shows:

failed to open /sys/dev/char/0:0/uevent

After multiple reboots it fixed itself and the stream works, but very unreliably.

Two things I noticed:
It uses quite a lot of CPU power (30-40%) and the stream has ~5 sec of delay.

Unfortunately after some more testing, I get these errors about 10 seconds after streaming.
The full command is:

./test-launch --gst-debug-level 1 "v4l2src device=/dev/video0 io-mode=2 ! image/jpeg, width=1280, height=960, framerate=30/1, format=MJPG ! nvjpegdec ! video/x-raw ! omxh264enc bitrate=1000000 control-rate=variable ! video/x-h264, profile=baseline ! rtph264pay name=pay0 pt=96" -p 8554
[INFO][/idrive_grpc][1587107475.924975]: [RTSP Server] 0:01:14.067983570 19412   0x7f90010cf0 ERROR             rtspclient rtsp-client.c:1054:find_media: client 0x55840c42f0: can't prepare media
[INFO][/idrive_grpc][1587107475.931521]: [RTSP Server] 0:01:14.068906746 19412   0x7f90010cf0 ERROR             rtspclient rtsp-client.c:2910:handle_describe_request: client 0x55840c42f0: no media
[INFO][/idrive_grpc][1587107475.946643]: [RTSP Server] 0:01:14.069203388 19412   0x7f90010cf0 ERROR             rtspclient rtsp-client.c:1258:handle_teardown_request: client 0x55840c42f0: no session

Hi,
You may confirm it is /dev/video0 or /dev/video1

I forgot to say that I finally got it to work, however only using the jpegdec. nvjpegdec has a memory leak and will crash the whole Jetson after roughly 2 minutes.