Source from usbcam and sink to rtsp

Hello, All

I’d like to get streaming from usbcam, and sink it into rtsp.
I read the code of “deepstream_test_1_usb.py” under usbcam and “deepstream_test1_rstp_out.py” under deepstream-test1-rtsp-out, and mixed the code together.

The main flow of the processing is as below:


source = Gst.ElementFactory.make(“v4l2src”, “usb-cam-source”)
decoder = Gst.ElementFactory.make(“nvv4l2decoder”, “nvv4l2-decoder”)
vidconvsrc = Gst.ElementFactory.make(“videoconvert”, “convertor_src1”)
nvvidconvsrc = Gst.ElementFactory.make(“nvvideoconvert”, “convertor_src2”)
caps_vidconvsrc = Gst.ElementFactory.make(“capsfilter”, “nvmm_caps”)
decoder = Gst.ElementFactory.make(“nvv4l2decoder”, “nvv4l2-decoder”)
streammux = Gst.ElementFactory.make(“nvstreammux”, “Stream-muxer”)
pgie = Gst.ElementFactory.make(“nvinfer”, “primary-inference”)
nvvidconv = Gst.ElementFactory.make(“nvvideoconvert”, “convertor”)
nvosd = Gst.ElementFactory.make(“nvdsosd”, “onscreendisplay”)
nvvidconv_postosd = Gst.ElementFactory.make(“nvvideoconvert”, “convertor_postosd”)
caps = Gst.ElementFactory.make(“capsfilter”, “filter”)
encoder = Gst.ElementFactory.make(“nvv4l2h264enc”, “encoder”)
rtppay = Gst.ElementFactory.make(“rtph264pay”, “rtppay”)
sink = Gst.ElementFactory.make(“udpsink”, “udpsink”)

source.link(decoder)
decoder.link(vidconvsrc)
vidconvsrc.link(nvvidconvsrc)
nvvidconvsrc.link(caps_vidconvsrc)

sinkpad = streammux.get_request_pad("sink_0")
if not sinkpad:
    sys.stderr.write(" Unable to get the sink pad of streammux \n")

srcpad = caps_vidconvsrc.get_static_pad("src")
if not srcpad:
    sys.stderr.write(" Unable to get source pad of decoder \n")

srcpad.link(sinkpad)
streammux.link(pgie)
pgie.link(nvvidconv)
nvvidconv.link(nvosd)
nvosd.link(nvvidconv_postosd)
nvvidconv_postosd.link(caps)
caps.link(encoder)
encoder.link(rtppay)
rtppay.link(sink)

The above flow can pass and run, but the weird thing is that the camera will get stuck at the first frame and as I move the camera, I cannot see the video get updated and be pushed to the rtsp server.

Where did I do wrong?
BTW, I am running on deepstream-sdk 5.0 on jetson nano

Thanks.

Can you run the USB cam app and RTSP app and confirm it can work well separately?

Also pls fill your setup info.

Thanks, I’ve solved the problem.