Gstreamer input-selector between udpsrc and videotestsrc not working

I’m trying to use the input-selector element to switch between a live video feed (udpsrc) and videotestsrc. My ultimate goal is to send it to the gst-rtsp-server.

I’m runnng the input-selector-test.c code from github-gstreamer blob

First let me post a few pipelines that work.

Pipeline #1 demonstrates the switching videotestsrc and udpsrc

pipeline = gst_parse_launch(“udpsrc port=5555 timeout=1000000020 ! application/x-rtp, media=video, clock-rate=90000, encoding-name=H265,playload=96 ! rtpjitterbuffer latency=5 do-lost=true ! rtph265depay ! h265parse ! video/x-h265,alignment=au ! nvv4l2decoder disable-dpb=true enable-max-performance=1 ! queue max-size-bytes=0 ! identity name=elm_id ! queue ! vs.sink_0 videotestsrc pattern=black ! vs.sink_1 input-selector name=vs ! nvvidconv ! nveglglessink window-width=720 window-height=480 sync=false qos=false”, NULL);

Pipeline #2 demonstrates the switching between two videotestsrc and outputting to a udpsink

pipeline = gst_parse_launch(“videotestsrc pattern=0 ! vs.sink_0 videotestsrc pattern=1”
" ! vs.sink_1 input-selector name=vs ! video/x-raw,width=640,height=480"
" ! nvvidconv"
" ! video/x-raw(memory:NVMM), format=I420,width=1920,height=1080, framerate=15/1"
" ! nvv4l2h264enc insert-sps-pps=1 profile=4"
" ! video/x-h264,stream-format=byte-stream"
" ! rtph264pay pt=96 "
“! udpsink host=127.0.0.1 port=11111 sync=false async=false”, NULL);

Pipeline#3 demonstrates the streaming of a udpsrc to a udpsink

pipeline = gst_parse_launch(“udpsrc port=5555 timeout=1000000020 !”
" application/x-rtp, media=video, clock-rate=90000, encoding-name=H265,playload=96 !"
" rtpjitterbuffer latency=5 do-lost=true !"
" rtph265depay !"
" h265parse !"
" video/x-h265,alignment=au !"
" nvv4l2decoder disable-dpb=true enable-max-performance=1 !"
" queue max-size-bytes=0 !"
" identity name=elm_id !"
" queue !"
" nvvidconv !"
" nvv4l2h264enc insert-sps-pps=1 profile=4 !"
" video/x-h264,stream-format=byte-stream !"
" rtph264pay pt=96 !"
" udpsink host=127.0.0.1 port=11111 sync=false async=false", NULL);

Using the three pipelines above, I created this Pipeline #4 to switch between udpsrc and videotestsrc and send it to the a udpsink

pipeline = gst_parse_launch(
" udpsrc port=5555 timeout=3000000020 !"
" application/x-rtp, media=video, clock-rate=90000, encoding-name=H265,playload=96 !"
" rtpjitterbuffer latency=5 do-lost=true !"
" rtph265depay !"
" h265parse !"
" video/x-h265,alignment=au !"
" nvv4l2decoder disable-dpb=true enable-max-performance=1 !"
" queue max-size-bytes=0 !"
" identity name=elm_id !"
" vs.sink_0 videotestsrc is-live=true pattern=0 !"
" vs.sink_1 input-selector name=vs !"
" nvvidconv !"
" video/x-raw(memory:NVMM), format=I420,width=1920,height=1080 !"
" nvv4l2h264enc insert-sps-pps=1 profile=4 !"
" video/x-h264,stream-format=byte-stream !"
" rtph264pay pt=96 !"
" udpsink host=127.0.0.1 port=11111 sync=false async=false", NULL);

The above pipeline streams alright until I try to switch input-selector active pad. At that point it throws an error.

0:00:01.568228480 18319 0x7f78003f20 WARN h265parse gsth265parse.c:1063:gst_h265_parse_handle_frame: broken/invalid nal Type: 38 FD, Size: 3 will be dropped
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279
0:00:01.750144288 18319 0x7f78003f20 WARN v4l2 gstv4l2object.c:4435:gst_v4l2_object_probe_caps:nvv4l2decoder0:src Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:01.750223552 18319 0x7f78003f20 WARN v4l2 gstv4l2object.c:2372:gst_v4l2_object_add_interlace_mode:0x556a7d7840 Failed to determine interlace mode
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:01.756999520 18319 0x556a7ed1e0 WARN v4l2bufferpool gstv4l2bufferpool.c:1057:gst_v4l2_buffer_pool_start:nvv4l2h264enc0:pool:src Uncertain or not enough buffers, enabling copy threshold
0:00:01.758034272 18319 0x7f78003f20 WARN v4l2videodec gstv4l2videodec.c:1623:gst_v4l2_video_dec_decide_allocation: Duration invalid, not setting latency
0:00:01.758496544 18319 0x7f78003f20 WARN v4l2bufferpool gstv4l2bufferpool.c:1057:gst_v4l2_buffer_pool_start:nvv4l2decoder0:pool:src Uncertain or not enough buffers, enabling copy threshold
0:00:01.773898240 18319 0x556a7ed050 WARN v4l2bufferpool gstv4l2bufferpool.c:1503:gst_v4l2_buffer_pool_dqbuf:nvv4l2decoder0:pool:src Driver should never set v4l2_buffer.field to ANY
H264: Profile = 100, Level = 0
0:00:01.796312064 18319 0x7f7c0048a0 WARN v4l2bufferpool gstv4l2bufferpool.c:1503:gst_v4l2_buffer_pool_dqbuf:nvv4l2h264enc0:pool:src Driver should never set v4l2_buffer.field to ANY
** Message: 12:44:28.736: switching
** Message: 12:44:28.737: switching1
** Message: 12:44:28.738: current number of sources : 2, active source sink_0
0:00:50.168575040 18319 0x7f7c0048a0 WARN v4l2allocator gstv4l2allocator.c:1492:gst_v4l2_allocator_dqbuf:nvv4l2h264enc0:pool:src:allocator V4L2 provided buffer has bytesused 0 which is too small to include data_offset 0
0:00:50.168862400 18319 0x556a7ed2d0 WARN videoencoder gstvideoencoder.c:678:gst_video_encoder_setcaps: rejected caps video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)3/4, interlace-mode=(string)progressive, format=(string)I420
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
0:00:50.172948384 18319 0x556a7ed2d0 WARN v4l2bufferpool gstv4l2bufferpool.c:1057:gst_v4l2_buffer_pool_start:nvv4l2h264enc0:pool:src Uncertain or not enough buffers, enabling copy threshold
nvbuf_utils: nvbuffer Payload Type not supported
NvBufferGetParams failed for src_dmabuf_fd
nvbuffer_transform Failed
gst_nvvconv_transform: NvBufferTransform Failed
0:00:50.175376704 18319 0x556a7ed2d0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop: error: Internal data stream error.
0:00:50.175401824 18319 0x556a7ed2d0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop: error: streaming stopped, reason error (-5)
Error: Internal data stream error.

I’m not sure why the nvv4l2h264enc is rejecting the caps? It did not throw such an error in Pipeline #3. I also don’t know what the is causing the NVBuf errors.