Runing gstreamer on Jetson with vs code


Not precisely right place to ask but I hope someone would be so kind.
I run gstreamer (very short one) on Jetson AGX Orin. I start from VS Code and I have selected Python3.8 with the interpreter. My problem is now that opening a gstreamer from my USB-camera I get nothing when running the python script from VS code.
But if I run the same code using sudo in a terminal, it works.

Can anyone help me how to figure out which package that seemingly is not installed as /usr or where the sudo is required? I would assume its either an installed package that is installed only to root or access rights to /dev/video0.


Could you try this sample:
V4l2src using OpenCV Gstreamer is not working in Jetson Xavier NX - #3 by DaneLLL

Would like to see if python OpenCV sample works.


This is the code I used and it works as Sudo.

sudo python3.8 #Works and camera capture starts
python3.8 #Does not work Can not open pipeline cap.isOpened() is False.
import sys
import cv2

def read_cam():
    G_STREAM_TO_SCREEN = "v4l2src device=/dev/video0 ! video/x-raw , width=(int)1600 , height=(int)1300 , format=(string)GRAY8 ! nvvidconv ! video/x-raw(memory:NVMM), width=(int)1600, height=(int)1300, format=I420 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR, width=(int)800 , height=(int)650 ! videoconvert ! appsink"
    cap = cv2.VideoCapture(G_STREAM_TO_SCREEN, cv2.CAP_GSTREAMER)
    #/dev/video2’, cv2.CAP_V4L
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img =
     print ("camera open failed")


if __name__ == '__main__':

I tested again by changing the pipeline to

G_STREAM_TO_SCREEN = "videotestsrc num-buffers=50 ! videoconvert ! appsink"

This creates the same issue so it has nothing to do with access to the camera src.

@WayneWWW any ideas

Please try this:
Nvoverlaysink ignores properties when pipeline is restarted - #6 by DaneLLL

See if it works without OpenCV. If it still fails, may try to build/run a gstreamer C sample. To check if it’s specific to python.

After running it I get nvoverlaysink error

loop = 1
Traceback (most recent call last):
File “”, line 16, in
pipeline = Gst.parse_launch(
gi.repository.GLib.Error: gst_parse_error: no element “nvoverlaysink” (1)

Just checking the gstreamer installation:

sudo apt-get install gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-good
Reading package lists… Done
Building dependency tree
Reading state information… Done
gstreamer1.0-libav is already the newest version (1.16.2-2).
gstreamer1.0-plugins-bad is already the newest version (1.16.2-2.1ubuntu1).
gstreamer1.0-plugins-ugly is already the newest version (1.16.2-2build1).
gstreamer1.0-plugins-base is already the newest version (1.16.2-4ubuntu0.1).
gstreamer1.0-plugins-good is already the newest version (1.16.2-1ubuntu2.1).
0 upgraded, 0 newly installed, 0 to remove and 137 not upgraded.

I managed to download gstreamer samples and compiled the basic-tutorial-1.c

gcc basic-tutorial-1.c -o basic-tutorial-1 `pkg-config --cflags --libs gstreamer-1.0`

This works. So the videostream with blender trailer works fine.

Since nvoverlaysink is deprecated on Jetpack 5, please try nvdrmvideosink or nv3dsink.

@DaneLLL Hi, I tried the nvdrmvideosink without sudo and it works with this pipeline:

pipeline = Gst.parse_launch(
“videotestsrc ! video/x-raw,width=1920,height=1080 ! nvvidconv ! video/x-raw(memory:NVMM),width=480,height=380,pixel-aspect-ratio=1/1 ! nv3dsink”

(Without the overlay)

This approach works in python without sudo., though I have no clue on how to fix openCV for python. Should I reinstall it? I tried also with one of your docker images and I got other errors then so I rather also stick with this native installation without virtual env.

The issue look specific to using OpenCV in VS code. We don’t have much experience about it and would need other users to share experience.

Found a link which may help:
Set Visual Studio code for OpenCV python |


The thing is. All the tests done, as you can see on how I execute python, has been from terminal. I have not used Code at all during the tests. So this is totally related to opencv/gstreamer and how something is not possible to access as user and not sudo user. I start to be willing to re-flash the orin and start from scratch. Or perhaps test via a virtual environment.

I am unable to install sudo apt-get install -y python-gst-1.0
I dont know why sudo would make a difference in running the code, but clearly the python-gst pack does not exist.

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package python-gst-1.0
E: Couldn’t find any package by glob ‘python-gst-1.0’
E: Couldn’t find any package by regex ‘python-gst-1.0’

I have re-flashed the Jetson from scratch and installing now Jetpack.
Any tutorial to follow from nVidia on how to get Yolo and gstreamer working on Jetpack5.0.1 dp?
I got yolo working after alot of reinstallation of pytorch and torchvision, but then I endid up stuck on gstreamer.
So now I will start with Gstreamer and document my steps in detail and present them here.

So. Reinstalling and reflashing Jetson Orin and reset it to initial state did the trick.
Now gstreamer works without sudo.

next step is to get it working with yoloV5 and I will open a new ticket when that fails :D

Thanks for your patience and support! I really apricate it!

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