Raspberry Pi 4B 上的 GStreamer RTSP 服务器管道
GStreamer RTSP server pipeline on Raspberry Pi 4B
我正在尝试为 Raspberry Pi 4B 上的相机设置 RTSP 服务器。我安装了 GStreamer 和 libgstrtspserver-1.0-dev(版本 1.14.4),并且正在使用 test-launch.c 脚本,用 gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
编译
然后我尝试使用管道
./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"
但是当我尝试从我的另一台计算机(通过 VLC 或 OpenCV)连接到它时,我在 Raspi 上收到了 GStreamer-CRITICAL 消息(我已经设置 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
连接失败。
我可以确认
gst-launch-1.0 v4l2src ! 'video/x-raw, width=1280, height=400, framerate=20/1, format=GRAY8' \
! videoconvert ! 'video/x-raw, format=I420' ! autovideosink
对我有用(可以很好地显示摄像头馈送),所以我想知道我的管道后面有什么问题,或者测试启动脚本是否出于某种原因在 Raspberry Pi 上不起作用?
我有一个类似的管道在我的 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"
所以我有点不知道 Raspberry Pi.
出了什么问题
编辑:
我做了一些进一步的测试,这条迂回的路线对我有用:
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
所以我想知道这是否是测试启动和 Raspberry Pi 的问题?
编辑2:
所以我运行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"
打印出来:
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)
所以我尝试了 sudo apt-get install --reinstall libglib2.0-0
但它没有任何改变
管道中多余的单引号导致了问题。
因此,工作管道将是:
./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"
我正在尝试为 Raspberry Pi 4B 上的相机设置 RTSP 服务器。我安装了 GStreamer 和 libgstrtspserver-1.0-dev(版本 1.14.4),并且正在使用 test-launch.c 脚本,用 gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
然后我尝试使用管道
./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"
但是当我尝试从我的另一台计算机(通过 VLC 或 OpenCV)连接到它时,我在 Raspi 上收到了 GStreamer-CRITICAL 消息(我已经设置 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
连接失败。
我可以确认
gst-launch-1.0 v4l2src ! 'video/x-raw, width=1280, height=400, framerate=20/1, format=GRAY8' \
! videoconvert ! 'video/x-raw, format=I420' ! autovideosink
对我有用(可以很好地显示摄像头馈送),所以我想知道我的管道后面有什么问题,或者测试启动脚本是否出于某种原因在 Raspberry Pi 上不起作用?
我有一个类似的管道在我的 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"
所以我有点不知道 Raspberry Pi.
出了什么问题编辑: 我做了一些进一步的测试,这条迂回的路线对我有用:
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
所以我想知道这是否是测试启动和 Raspberry Pi 的问题?
编辑2:
所以我运行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"
打印出来:
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)
所以我尝试了 sudo apt-get install --reinstall libglib2.0-0
但它没有任何改变
管道中多余的单引号导致了问题。 因此,工作管道将是:
./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"