-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv4l2loopback.py
More file actions
27 lines (26 loc) · 844 Bytes
/
v4l2loopback.py
File metadata and controls
27 lines (26 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
import os
def create_virtcam(video_nr):
device_path = f'/dev/video{video_nr}'
if not os.path.exists(device_path):
print(f"Creating it at {device_path}...")
try:
subprocess.run([
'sudo',
'modprobe',
'v4l2loopback',
f'video_nr={video_nr}',
'width=1280',
'height=720',
'pixelformat=YUYV',
'card_label="Samsung"',
'exclusive_caps=1'
], check=True)
print("Virtual Camera created successfully.")
return True
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
return False
else:
print(f"Virtual Camera already exists at {device_path}.")
return True