letmaik / pyvirtualcam

🎥 Send frames to a virtual camera from Python
GNU General Public License v2.0
455 stars 49 forks source link

Resolution of framebuffer is not verified #17

Closed JayFoxRox closed 3 years ago

JayFoxRox commented 3 years ago

User passes explicit size here:

https://github.com/letmaik/pyvirtualcam/blob/44b4184b5cae2edaec45e974babff9ebcf9ff410/pyvirtualcam/native_windows/main.cpp#L8-L11

Framebuffer is then passed here:

https://github.com/letmaik/pyvirtualcam/blob/44b4184b5cae2edaec45e974babff9ebcf9ff410/pyvirtualcam/native_windows/main.cpp#L13-L27

However, the framebuffer can be much larger or smaller than the set width / height. This could lead to buffer-overflows probably.

agilebean commented 1 year ago

is this issue related to the error

pixel buffer size mismatch

when running:

ideo = cv2.VideoCapture(args.video_path)
if not video.isOpened():
    raise ValueError("error opening video")
length = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = video.get(cv2.CAP_PROP_FPS)

print(f"width {width} height{height}")

with pyvirtualcam.Camera(width=width, height=height, fps=fps, fmt=PixelFormat.BGR,
                         device=args.device) as cam:
...