I'm trying to set up a RTSP server for my camera on my Raspberry Pi 4B. I installed GStreamer and libgstrtspserver-1.0-dev (version 1.14.4), and am using the test-launch.c script, compiled with gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
I then try to use the pipeline
./test-launch "v4l2src ! 'video/x-raw, width=1280, height=400, framerate=20/1, format=GRAY8' \
! videoconvert ! 'video/x-raw, format=I420' ! v4l2h264enc ! 'video/x-h264, stream-format=byte-stream, \
alignment=au' ! h264parse ! rtph264pay name=pay0 pt=96"
but when I try to connect to it from my other computer (through VLC or OpenCV), I get the GStreamer-CRITICAL messages on the Raspi (I've set GST_DEBUG=4
):
j@JRaspi:~/server $ ./test-launch "v4l2src device='/dev/video0' ! 'video/x-raw, width=1280, height=400, format=GRAY8, framerate=20/1' ! videoconvert ! 'video/x-raw, format=I420' ! v4l2h264enc ! 'video/x-h264, stream-format=byte-stream, alignment=au' ! h264parse ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
(test-launch:8246): GStreamer-CRITICAL **: 14:56:54.865: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:8246): GStreamer-CRITICAL **: 14:56:54.865: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:8246): GStreamer-CRITICAL **: 14:56:54.865: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
and a failed connection.
I can confirm that
gst-launch-1.0 v4l2src ! 'video/x-raw, width=1280, height=400, framerate=20/1, format=GRAY8' \
! videoconvert ! 'video/x-raw, format=I420' ! autovideosink
works for me (displays the camera feed well), so I'm wondering what's wrong with the back of my pipeline or does the test-launch script not work on the Raspberry Pi for some reason?
I've got a similar pipeline working just fine on my Jetson Nano:
./test-launch "v4l2src ! video/x-raw, width=1280, height=400, framerate=20/1, format=GRAY8 \
! nvvidconv ! video/x-raw(memory:NVMM), format=(string)I420 ! omxh264enc ! video/x-h264, \
stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96"
so I'm kind of lost what's wrong on the Raspberry Pi.
EDIT: I did some further testing and this circuitous route works for me:
gst-launch-1.0 v4l2src ! 'video/x-raw, width=1280, height=400, \
format=GRAY8' ! videoconvert ! 'video/x-raw, format=I420'\
! v4l2h264enc ! 'video/x-h264, stream-format=byte-stream, alignment=au' \
! h264parse ! rtph264pay name=pay0 pt=96 ! rtph264depay ! h264parse \
! decodebin ! videoconvert ! autovideosink
so I'm wondering if it's a problem with test-launch and Raspberry Pi?
EDIT2:
So I ran G_DEBUG=fatal-criticals gdb -ex run --args test-launch "v4l2src ! 'video/x-raw, width=1280, height=400, format=GRAY8' ! videoconvert ! 'video/x-raw, format=I420' ! v4l2h264enc ! 'video/x-h264, stream-format=byte-stream, alignment=au' ! h264parse ! rtph264pay name=pay0 pt=96"
which printed out:
Reading symbols from test-launch...(no debugging symbols found)...done.
Starting program: /home/joel/Arducam-Stereo-RPI/server/test-launch v4l2src\ \!\ \'video/x-raw,\ width=1280,\ height=400,\ format=GRAY8\'\ \!\ videoconvert\ \!\ \'video/x-raw,\ format=I420\'\ \!\ v4l2h264enc\ \!\ \'video/x-h264,\ stream-format=byte-stream,\ alignment=au\'\ \!\ h264parse\ \!\ rtph264pay\ name=pay0\ pt=96
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
stream ready at rtsp://127.0.0.1:8554/test
[New Thread 0xb657b3a0 (LWP 2529)]
(test-launch:2524): GStreamer-CRITICAL **: 16:46:07.769: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:2524): GStreamer-CRITICAL **: 16:46:07.787: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:2524): GStreamer-CRITICAL **: 16:46:07.788: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
[New Thread 0xb57743a0 (LWP 2530)]
(test-launch:2524): GStreamer-CRITICAL **: 16:46:27.960: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:2524): GStreamer-CRITICAL **: 16:46:27.960: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
(test-launch:2524): GStreamer-CRITICAL **: 16:46:27.960: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
[Thread 0xb57743a0 (LWP 2530) exited]
[Thread 0xb657b3a0 (LWP 2529) exited]
^C
Thread 1 "test-launch" received signal SIGINT, Interrupt.
__GI___poll (timeout=-1, nfds=2, fds=0x2e7e0)
--Type <RET> for more, q to quit, c to continue without paging--
at ../sysdeps/unix/sysv/linux/poll.c:29
29 ../sysdeps/unix/sysv/linux/poll.c: No such file or directory.
(gdb) bt
#0 0xb6b4dcd0 in __GI___poll (timeout=-1, nfds=2, fds=0x2e7e0)
at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0xb6b4dcd0 in __GI___poll (fds=0x2e7e0, nfds=2, timeout=-1)
at ../sysdeps/unix/sysv/linux/poll.c:26
#2 0xb6c45eb4 in () at /usr/lib/arm-linux-gnueabihf/libglib-2.0.so.0
(gdb)
So I tried sudo apt-get install --reinstall libglib2.0-0
but it didn't change anything
The extra single quotation marks in the pipeline caused the problem. So a working pipeline would be:
./test-launch "v4l2src ! video/x-raw, width=1280, height=400, format=GRAY8 \
! videoconvert ! video/x-raw, format=I420 ! v4l2h264enc ! video/x-h264, \
stream-format=byte-stream, alignment=au ! h264parse ! rtph264pay name=pay0 pt=96"