你可以使用 OpenCV 库在 Python 中调用摄像头并保存视频。下面是一个简单的代码示例:
import cv2
# 打开摄像头
cap = cv2.VideoCapture(0)
# 设置编码器和保存视频的文件名
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
while True:
# 读取帧
ret, frame = cap.read()
if not ret:
brea