# Deepstream multistream with USB webcam python?

**URL:** <https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802>\
**Category:** DeepStream SDK\
**Tags:** camera\
**Created:** [October 23, 2020, 6:33am UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802 "2020-10-23T06:33:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![khuomdt3](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@khuomdt3](https://forums.developer.nvidia.com/u/khuomdt3)\
**Post date:** [October 23, 2020, 6:33am UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802/1 "2020-10-23T06:33:04Z")

</div>

i can run python multistream with 2 webcam already!  
Can i run it with python3 code?  
How can i run mutilstream like [deepstream-imagedata-multistream](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-imagedata-multistream) and USB webcam like [deepstream-test1-usbcam](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-test1-usbcam) at one???  
Thank you

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU)** Jetson Nano/Xavier  
**• DeepStream Version** 5.0.1  
**• JetPack Version (valid for Jetson only)** 4.4  
**• TensorRT Version** 7.1.3  
**• Issue Type( questions, new requirements, bugs)** questions

---

<div class="post-metadata">

**Author:** ![mchi](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/mchi/32/14043_2.png) [@mchi](https://forums.developer.nvidia.com/u/mchi)\
**Post date:** [October 23, 2020, 3:38pm UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802/3 "2020-10-23T15:38:31Z")

</div>

What does USB webcam? Is it a USB camera connected to the USB port of Jetson device or a web camera connected to ethernet port?

Do you want to use webcamera as source for [deepstream-imagedata-multistream](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-imagedata-multistream)? If it’s, you can change the source to webcamera referring to [deepstream-test1-usbcam](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/tree/master/apps/deepstream-test1-usbcam).

So, what issue are you facing? can you be more specific?

---

<div class="post-metadata">

**Author:** ![khuomdt3](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@khuomdt3](https://forums.developer.nvidia.com/u/khuomdt3)\
**Post date:** [October 24, 2020, 2:22am UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802/4 "2020-10-24T02:22:35Z")

</div>

- I tried what you say and complete this code (below) ! is this code good? i feel like it’s a little slow and not optimize!  
Can you check it?

- And i can not use “usb\_cam\_source.connect(“child-added”,decodebin\_child\_added,nbin)” in my code either!

ERR: “TypeError: \< **gi**.GstV4l2Src object at 0x7f8a016ab0 (GstV4l2Src at 0x361ee270)\>: unknown signal name: child-added”

- And can i get fps of the system?

- _Note_: I ran this code with yolov4 enigine, batchsize =2 and i set the tiler’s width-height are 480-320.

**Thank you for your reply**

```
def create_source_bin(index,uri):
    print("Creating source bin")
    bin_name="source-bin-%02d" %index
    print(bin_name)
    nbin=Gst.Bin.new(bin_name)
    if not nbin:
        sys.stderr.write(" Unable to create source bin \n")

    usb_cam_source=Gst.ElementFactory.make("v4l2src", "usb-cam-source")
    usb_cam_source.set_property("device",uri)
    usb_cam_source.connect("pad-added",cb_newpad,nbin)
    #usb_cam_source.connect("child-added",decodebin_child_added,nbin)
    caps_v4l2src = Gst.ElementFactory.make("capsfilter", "v4l2src_caps")
    if not caps_v4l2src:
        sys.stderr.write(" Unable to create v4l2src capsfilter \n")
    vidconvsrc = Gst.ElementFactory.make("videoconvert", "convertor_src1")
    if not vidconvsrc:
        sys.stderr.write(" Unable to create videoconvert \n")
    nvvidconvsrc = Gst.ElementFactory.make("nvvideoconvert", "convertor_src2")
    if not nvvidconvsrc:
        sys.stderr.write(" Unable to create Nvvideoconvert \n")
    
    caps_vidconvsrc = Gst.ElementFactory.make("capsfilter", "nvmm_caps")
    if not caps_vidconvsrc:
        sys.stderr.write(" Unable to create capsfilter \n")

    caps_vidconvsrc.set_property('caps', Gst.Caps.from_string("video/x-raw(memory:NVMM)"))
    caps_v4l2src.set_property('caps', Gst.Caps.from_string("video/x-raw, framerate=30/1"))

    print('adding element to source bin')
    Gst.Bin.add(nbin,usb_cam_source)

    Gst.Bin.add(nbin, caps_v4l2src)
    Gst.Bin.add(nbin, vidconvsrc)
    Gst.Bin.add(nbin,nvvidconvsrc)
    Gst.Bin.add(nbin,caps_vidconvsrc)

    print('linking elemnent in source bin')
    nvvidconvsrc.link(caps_vidconvsrc)
    usb_cam_source.link(caps_v4l2src)
    caps_v4l2src.link(vidconvsrc)
    vidconvsrc.link(nvvidconvsrc)
    nvvidconvsrc.link(caps_vidconvsrc)

    pad = caps_vidconvsrc.get_static_pad("src")
    ghostpad = Gst.GhostPad.new("src",pad)
    bin_pad=nbin.add_pad(ghostpad)
    if not bin_pad:
        sys.stderr.write(" Failed to add ghost pad in source bin \n")
        return None
    return nbin

```

---

<div class="post-metadata">

**Author:** ![mchi](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/mchi/32/14043_2.png) [@mchi](https://forums.developer.nvidia.com/u/mchi)\
**Post date:** [October 27, 2020, 2:32pm UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802/5 "2020-10-27T14:32:11Z")

</div>

please refer to **[DS5.0GA\_Jetson\_GPU\_Plugin] Measure of the FPS of pipeline** in [DeepStream SDK FAQ - #9 by mchi](https://forums.developer.nvidia.com/t/deepstream-sdk-faq/80236/9) to measure the fps.

What your platform ? NANO or Xavier?  
Could you measure the trtexec performance of your trtengine by referring to [GitHub - NVIDIA-AI-IOT/deepstream\_tao\_apps: Sample apps to demonstrate how to deploy models trained with TAO on DeepStream](https://github.com/NVIDIA-AI-IOT/deepstream_tlt_apps#measure-the-inference-perf) ?

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:16pm UTC](https://forums.developer.nvidia.com/t/deepstream-multistream-with-usb-webcam-python/157802/7 "2021-10-12T16:16:13Z")

</div>

Closed on October 12, 2021, 4:16pm UTC


