Issues Testing Gstreamer RTSP Server with USB Camera and Hardware Encoding on Jetson Orin Nx

Hello, I recently attempted to build a hardware-encoded RTSP service using GStreamer on the Jetson Orin Nx and encountered some issues. It would be greatly appreciated if you could provide some troubleshooting insights.

Platform Information:

USB Camera Details:



Software Encoding Test:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "videotestsrc ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
0:00:04.668716192 42335 0xffffa400e460 FIXME                default gstutils.c:3980:gst_pad_create_stream_id_internal:<videotestsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:04.703048832 42335 0xaaaaeca9e860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:04.704353920 42335 0xaaaaeca9e860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:04.704391424 42335 0xaaaaeca9e860 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffffac0411e0 was not prepared
0:00:04.708347104 42335 0xaaaaeca9e860 FIXME             rtspclient rtsp-client.c:1818:handle_play_request:<GstRTSPClient@0xaaaaeca995d0> Add support for seek style (null)

==============================================================================================================================================================================

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=60/1 ! videoconvert !  video/x-raw,format=I420 ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
0:00:06.907428576 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:06.909641031 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:06.909715080 38909 0xaaaade727860 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffffb404c220 was not prepared
0:00:06.915983677 38909 0xaaaade727860 FIXME             rtspclient rtsp-client.c:1818:handle_play_request:<GstRTSPClient@0xaaaade7225d0> Add support for seek style (null)
0:00:06.916080861 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:2711:gst_rtsp_media_seek_full:<GstRTSPMedia@0xffffb404c220> Handle going back to 0 for none live not seekable streams.
0:00:18.730400637 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:12.668209285
0:00:22.686792061 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:16.618113349
0:00:23.280293117 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:17.218097605

Result: Playable normally via VLC.

Hardware Encoding Test:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "videotestsrc ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
0:00:12.766426593 39704 0xaaaaf3851b00 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffffa419ec20 Failed to determine interlace mode
0:00:12.766498529 39704 0xaaaaf3851b00 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffffa419ec20 Failed to determine interlace mode
0:00:12.766525729 39704 0xaaaaf3851b00 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffffa419ec20 Failed to determine interlace mode
0:00:12.766547201 39704 0xaaaaf3851b00 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffffa419ec20 Failed to determine interlace mode
0:00:12.766622401 39704 0xaaaaf3851b00 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:12.767443937 39704 0xffff7800f4c0 FIXME                default gstutils.c:3980:gst_pad_create_stream_id_internal:<videotestsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:12.770273153 39704 0xffff7800f4c0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2h264enc0:pool:src> Uncertain or not enough buffers, enabling copy threshold
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 126000
NvVideo: bBlitMode is set to TRUE
0:00:12.783189537 39704 0xffff7800f5e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2h264enc0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:12.784922241 39704 0xaaaaf3851860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:12.785869281 39704 0xaaaaf3851860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:12.785908289 39704 0xaaaaf3851860 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffffa41c7250 was not prepared
0:00:12.837420417 39704 0xaaaaf3851860 ERROR             rtspclient rtsp-client.c:1882:handle_play_request: client 0xaaaaf384c700: media not found
0:00:12.838569377 39704 0xaaaaf3851860 ERROR             rtspclient rtsp-client.c:1432:handle_teardown_request: client 0xaaaaf384c700: no media for uri
0:00:12.850406817 39704 0xaaaaf3851860 WARN               rtspmedia rtsp-media.c:4520:gst_rtsp_media_set_state: media 0xffffa41c7250 was not prepared
Opening in BLOCKING MODE
0:00:15.257646881 39704 0xffffa4003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff64003370 Failed to determine interlace mode
0:00:15.257700385 39704 0xffffa4003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff64003370 Failed to determine interlace mode
0:00:15.257728737 39704 0xffffa4003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff64003370 Failed to determine interlace mode
0:00:15.257751745 39704 0xffffa4003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff64003370 Failed to determine interlace mode
0:00:15.257805409 39704 0xffffa4003de0 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc1:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:15.258687777 39704 0xaaaaf3851760 FIXME                default gstutils.c:3980:gst_pad_create_stream_id_internal:<videotestsrc1:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:15.260850689 39704 0xaaaaf3851760 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2h264enc1:pool:src> Uncertain or not enough buffers, enabling copy threshold
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 126000
NvVideo: bBlitMode is set to TRUE
0:00:15.274103777 39704 0xaaaaf3851aa0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2h264enc1:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:15.275241345 39704 0xffffa4003460 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:15.276842241 39704 0xffffa4003460 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:15.276877857 39704 0xffffa4003460 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffff640111c0 was not prepared
0:00:15.281307201 39704 0xffffa4003460 FIXME             rtspclient rtsp-client.c:1818:handle_play_request:<GstRTSPClient@0xaaaaf384c960> Add support for seek style (null)
0:00:15.281365921 39704 0xffffa4003460 FIXME              rtspmedia rtsp-media.c:2711:gst_rtsp_media_seek_full:<GstRTSPMedia@0xffff640111c0> Handle going back to 0 for none live not seekable streams.

==============================================================================================================================================================================

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
0:00:10.921622381 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921702610 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921729396 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921750517 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921838075 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:11.118833609 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:11.118880076 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
0:00:11.118982098 43668 0xffff9c003460 WARN               rtspmedia rtsp-media.c:3001:default_handle_message: 0xffff9c1cd260: got error Internal data stream error. (gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4))
0:00:11.119026293 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3272:wait_preroll: failed to preroll pipeline
0:00:11.119057239 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3652:gst_rtsp_media_prepare: failed to preroll pipeline
0:00:11.121733819 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:1077:find_media: client 0xaaaae659f5d0: can't prepare media
0:00:11.122072048 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:2963:handle_describe_request: client 0xaaaae659f5d0: no media
Opening in BLOCKING MODE
0:00:11.157843553 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157895364 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157921286 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157942887 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157994474 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc1:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
0:00:11.189076316 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src1> error: Internal data stream error.
0:00:11.189109182 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src1> error: streaming stopped, reason not-negotiated (-4)
0:00:11.189208516 43668 0xffff9c003460 WARN               rtspmedia rtsp-media.c:3001:default_handle_message: 0xffff9c1cd440: got error Internal data stream error. (gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin1/GstV4l2Src:v4l2src1:
streaming stopped, reason not-negotiated (-4))
0:00:11.189252038 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3272:wait_preroll: failed to preroll pipeline
0:00:11.189272552 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3652:gst_rtsp_media_prepare: failed to preroll pipeline
0:00:11.191459982 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:1077:find_media: client 0xaaaae659f700: can't prepare media
0:00:11.191777313 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:2692:handle_setup_request: client 0xaaaae659f700: media '/test' not found

Result:

  1. When using videotestsrc, VLC fails to open the stream properly on the first attempt but succeeds on the second attempt.
  2. When using v4l2src device=/dev/video0, VLC cannot open the stream normally.

Could you help me diagnose where the problem might lie?

Hi,
We run the command on Orin NX developer kit:

$ GST_DEBUG=3 ./test-launch "videotestsrc ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96"

And can decode it through VLC player on host PC. Not sure if it helps but you may try videotestsrc is-live=1

And may try UDP:
Jetson AGX Orin FAQ

Hi, I’m glad to receive your reply.

I tried videotestsrc is-live=1, but as before, it always fails to open on the first attempt and works on the second try.

Actually, my main issue is not this. Instead, it’s about how to generate an RTSP video stream service via hardware encoding with a USB camera.

Currently, I can successfully generate an RTSP video stream service through software encoding with GStreamer, as follows:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=60/1 ! videoconvert !  video/x-raw,format=I420 ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
0:00:06.907428576 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:06.909641031 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:06.909715080 38909 0xaaaade727860 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffffb404c220 was not prepared
0:00:06.915983677 38909 0xaaaade727860 FIXME             rtspclient rtsp-client.c:1818:handle_play_request:<GstRTSPClient@0xaaaade7225d0> Add support for seek style (null)
0:00:06.916080861 38909 0xaaaade727860 FIXME              rtspmedia rtsp-media.c:2711:gst_rtsp_media_seek_full:<GstRTSPMedia@0xffffb404c220> Handle going back to 0 for none live not seekable streams.
0:00:18.730400637 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:12.668209285
0:00:22.686792061 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:16.618113349
0:00:23.280293117 38909 0xffffac00e460 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:17.218097605

However, when switching to hardware encoding, it fails and reports an error:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
0:00:10.921622381 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921702610 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921729396 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921750517 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1a5e00 Failed to determine interlace mode
0:00:10.921838075 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:11.118833609 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:11.118880076 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
0:00:11.118982098 43668 0xffff9c003460 WARN               rtspmedia rtsp-media.c:3001:default_handle_message: 0xffff9c1cd260: got error Internal data stream error. (gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4))
0:00:11.119026293 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3272:wait_preroll: failed to preroll pipeline
0:00:11.119057239 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3652:gst_rtsp_media_prepare: failed to preroll pipeline
0:00:11.121733819 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:1077:find_media: client 0xaaaae659f5d0: can't prepare media
0:00:11.122072048 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:2963:handle_describe_request: client 0xaaaae659f5d0: no media
Opening in BLOCKING MODE
0:00:11.157843553 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157895364 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157921286 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157942887 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff9c1aa830 Failed to determine interlace mode
0:00:11.157994474 43668 0xffff9c003460 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc1:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
0:00:11.189076316 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src1> error: Internal data stream error.
0:00:11.189109182 43668 0xffff7400f4c0 WARN                 basesrc gstbasesrc.c:3072:gst_base_src_loop:<v4l2src1> error: streaming stopped, reason not-negotiated (-4)
0:00:11.189208516 43668 0xffff9c003460 WARN               rtspmedia rtsp-media.c:3001:default_handle_message: 0xffff9c1cd440: got error Internal data stream error. (gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin1/GstV4l2Src:v4l2src1:
streaming stopped, reason not-negotiated (-4))
0:00:11.189252038 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3272:wait_preroll: failed to preroll pipeline
0:00:11.189272552 43668 0xaaaae65a4860 WARN               rtspmedia rtsp-media.c:3652:gst_rtsp_media_prepare: failed to preroll pipeline
0:00:11.191459982 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:1077:find_media: client 0xaaaae659f700: can't prepare media
0:00:11.191777313 43668 0xaaaae65a4860 ERROR             rtspclient rtsp-client.c:2692:handle_setup_request: client 0xaaaae659f700: media '/test' not found

I can’t figure out the cause of the problem.

Hi,
Please try the command and see if you can get a good video file:

$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=150 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=(string)I420' ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=a.mkv

I tried the command you provided, but it failed to generate a good video file:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=150 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=(string)I420' ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=a.mkv
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000082801
Setting pipeline to NULL ...
Freeing pipeline ...

Hi, the error indicates the v4l2 source fails to run in 640*480p30 YUY2. Suggest check this.

Thank you very much for your solution. I have found the problem. I previously thought that as long as the set frame rate did not exceed the maximum frame rate of the USB camera, it would be fine, so I only set it to 30 FPS. However, when I changed it to 60 FPS, it played normally.

But there is still one last issue: why does VLC software always fail to connect on the first attempt and succeed on the second attempt after generating the RTSP service? The first connection failure is accompanied by the error output:

0:00:17.476922336 1148704 0xaaaabf72dc60 ERROR             rtspclient rtsp-client.c:1882:handle_play_request: client 0xaaaabf728700: media not found
0:00:17.477813411 1148704 0xaaaabf72dc60 ERROR             rtspclient rtsp-client.c:1432:handle_teardown_request: client 0xaaaabf728700: no media for uri

All outputs are as follows:

xxx@ubuntu:~/gst-rtsp-server-1.16.3/examples$ GST_DEBUG=3 ./test-launch "v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=60/1 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h264enc ! h264parse ! rtph264pay name=pay0 pt=96"
stream ready at rtsp://127.0.0.1:8554/test
Opening in BLOCKING MODE
0:00:16.366018747 1148704 0xffff98003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff981a6600 Failed to determine interlace mode
0:00:16.366093227 1148704 0xffff98003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff981a6600 Failed to determine interlace mode
0:00:16.366134291 1148704 0xffff98003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff981a6600 Failed to determine interlace mode
0:00:16.366155480 1148704 0xffff98003460 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff981a6600 Failed to determine interlace mode
0:00:16.366244906 1148704 0xffff98003460 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:16.581410742 1148704 0xffff7000f4c0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2h264enc0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:16.606363325 1148704 0xffff7000f4c0 WARN          v4l2bufferpool gstv4l2bufferpool.c:809:gst_v4l2_buffer_pool_start:<v4l2src0:pool:src> Uncertain or not enough buffers, enabling copy threshold
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 252000
NvVideo: bBlitMode is set to TRUE
0:00:17.422640790 1148704 0xffff7000f5e0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2h264enc0:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:17.424342028 1148704 0xaaaabf72dc60 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:17.424911540 1148704 0xaaaabf72dc60 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:17.424934072 1148704 0xaaaabf72dc60 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffff981cc260 was not prepared
0:00:17.476922336 1148704 0xaaaabf72dc60 ERROR             rtspclient rtsp-client.c:1882:handle_play_request: client 0xaaaabf728700: media not found
0:00:17.477813411 1148704 0xaaaabf72dc60 ERROR             rtspclient rtsp-client.c:1432:handle_teardown_request: client 0xaaaabf728700: no media for uri
0:00:17.520507212 1148704 0xaaaabf72dc60 WARN               rtspmedia rtsp-media.c:4520:gst_rtsp_media_set_state: media 0xffff981cc260 was not prepared
Opening in BLOCKING MODE
0:00:32.881289319 1148704 0xffff98003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff580051a0 Failed to determine interlace mode
0:00:32.881346084 1148704 0xffff98003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff580051a0 Failed to determine interlace mode
0:00:32.881371587 1148704 0xffff98003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff580051a0 Failed to determine interlace mode
0:00:32.881396450 1148704 0xffff98003de0 WARN                    v4l2 gstv4l2object.c:2420:gst_v4l2_object_add_interlace_mode:0xffff580051a0 Failed to determine interlace mode
0:00:32.881452799 1148704 0xffff98003de0 WARN                    v4l2 gstv4l2object.c:4561:gst_v4l2_object_probe_caps:<nvv4l2h264enc1:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:33.136926438 1148704 0xffff980036a0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1114:gst_v4l2_buffer_pool_start:<nvv4l2h264enc1:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:33.173918727 1148704 0xffff980036a0 WARN          v4l2bufferpool gstv4l2bufferpool.c:809:gst_v4l2_buffer_pool_start:<v4l2src1:pool:src> Uncertain or not enough buffers, enabling copy threshold
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 252000
NvVideo: bBlitMode is set to TRUE
0:00:33.991043209 1148704 0xffff98003400 WARN          v4l2bufferpool gstv4l2bufferpool.c:1565:gst_v4l2_buffer_pool_dqbuf:<nvv4l2h264enc1:pool:src> Driver should never set v4l2_buffer.field to ANY
0:00:33.992547372 1148704 0xffff98003580 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:33.994357980 1148704 0xffff98003580 FIXME              rtspmedia rtsp-media.c:4201:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing
0:00:33.994389690 1148704 0xffff98003580 WARN               rtspmedia rtsp-media.c:4227:gst_rtsp_media_suspend: media 0xffff580121a0 was not prepared
0:00:33.999134549 1148704 0xffff98003580 FIXME             rtspclient rtsp-client.c:1818:handle_play_request:<GstRTSPClient@0xaaaabf728960> Add support for seek style (null)
0:00:33.999453794 1148704 0xffff98003580 FIXME              rtspmedia rtsp-media.c:2711:gst_rtsp_media_seek_full:<GstRTSPMedia@0xffff580121a0> Handle going back to 0 for none live not seekable streams.

Hi,
You may try another PC. On my laptop, I always succeed to receive and decode RTSP in first launch.

Or may try $ gst-launch-1.0 rtspsrc ! … command.

I used the method you recommended and it indeed opened successfully on the first try. Maybe there was an issue with VLC.
I have no further problems now. Thank you again for your help.

1 Like

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