Giter Club home page Giter Club logo

Comments (4)

letmaik avatar letmaik commented on September 15, 2024

Does it happen reproducibly? It looks like an issue with v4l2loopback. Maybe you started the script twice somehow? Or another software is writing to the camera as well and has re-configured it after starting the Python script. The error message doesn't say much, so it's hard to tell.

from pyvirtualcam.

mortal-Zero avatar mortal-Zero commented on September 15, 2024

Does it happen reproducibly? It looks like an issue with v4l2loopback. Maybe you started the script twice somehow? Or another software is writing to the camera as well and has re-configured it after starting the Python script. The error message doesn't say much, so it's hard to tell.

ok, thanks for your reply, I will try to reinstall v4l2loopback.

from pyvirtualcam.

mortal-Zero avatar mortal-Zero commented on September 15, 2024

Does it happen reproducibly? It looks like an issue with v4l2loopback. Maybe you started the script twice somehow? Or another software is writing to the camera as well and has re-configured it after starting the Python script. The error message doesn't say much, so it's hard to tell.

Sorry to bother you again, I am having some problems with pyvituralcam.
when I with pyvirtualcam.Camera(width=1920, height=1080, fps=30) as cam and cam.send(frame), can I use cv2.VideoCapture(0) to get the frame? My computer has only one camera created by v4l2loopback, '/dev/video0'.

this is my code:

import os
import sys

import cv2
import numpy as np
import pyvirtualcam


if __name__ == "__main__":
    video_path = '/workspace/test_virtual_camera/demo_video/demo.mp4'

    video_capture = cv2.VideoCapture(video_path)
    frame_height = video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)
    frame_width = video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)
    frame_count = video_capture.get(cv2.CAP_PROP_FRAME_COUNT)
    fps = video_capture.get(cv2.CAP_PROP_FPS)

    frame_rgb_list = []
    for frame_idx in range(int(frame_count)):
        _, frame = video_capture.read()
        frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        frame_rgb_list.append(frame_rgb)

    with pyvirtualcam.Camera(width=int(frame_width),
                             height=int(frame_height),
                             fps=int(fps)) as cam:
        print(f'Using virtual camera: {cam.device}')

        video_capture_virtualcam = cv2.VideoCapture(0)

        n = 0
        while True:
            frame = frame_rgb_list[n]
            cam.send(frame)
            cam.sleep_until_next_frame()

            ret, frame_from_virtualcam = video_capture_virtualcam.read()
            cv2.imshow("frame_from_virtualcam", frame_from_virtualcam)
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
            if n == 10:
                break
            print('==>>', n)
            n += 1

        video_capture_virtualcam.release()
        cv2.destroyAllWindows()

        sys.exit()

from pyvirtualcam.

letmaik avatar letmaik commented on September 15, 2024

Can you confirm whether you fixed your original issue? If so, please close this github issue. You can use the Discussions to ask further questions.

from pyvirtualcam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.