OpenCV virtual camera working on Ubuntu desktop PC, but not on Jetson Nano

I have made this OPENCV code which takes the camera video, add a mask.jpg to it and create a new “fake” virtual camera out of it. It’s working well on my Ubuntu Desktop PC, but I can’t make it work on Jetson Nano. Spent all day on it, but still getting this error. Can anyone help me, please? (Also tried both CSI and USB webcam, with the same result)


Traceback (most recent call last):
  File "/home/scotty/dice_mask/", line 31, in <module>
    with pyvirtualcam.Camera(width=640, height=480, fps=20) as cam:
  File "/home/scotty/.local/lib/python3.6/site-packages/pyvirtualcam/", line 219, in __init__
    raise RuntimeError('\n'.join(errors))
RuntimeError: 'v4l2loopback' backend: std::exception


import cv2
import numpy as np
import pyvirtualcam

flip = 2
dispW = 640
dispH = 480

camSet='nvarguscamerasrc !  video/x-raw(memory:NVMM), width=3280, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
img2 = cv2.imread('/home/scotty/dice_mask/mask_480.jpg')

# Check if camera opened successfully
if (cap.isOpened()== False): 
  print("Error opening video stream or file")

# Read until video is completed
  # Capture frame-by-frame
  ret, frame =
  if ret == True:

    # Display the resulting frame
    dst = cv2.addWeighted(frame,1,img2,1,0)
    #creating virtual camera /dev/video2
    with pyvirtualcam.Camera(width=640, height=480, fps=20) as cam:
      print(f'Using virtual camera: {cam.device}')

      framex = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)

    # Press Q on keyboard to  exit
    if cv2.waitKey(25) & 0xFF == ord('q'):

  # Break the loop

# When everything is done, release the video capture object

# Closes all the frames

Please check if you can run this app and see preview:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL