简体   繁体   English

如何在20秒后从python中的网络摄像头视频开始捕获视频帧

[英]How to start capture video frame after 20sec from webcam video in python

Somebody do help me to solve this problem. 有人帮我解决了这个问题。 When the program starts execute, the webcam get starts to capture the video as an input. 当程序开始执行时,网络摄像头开始捕获视频作为输入。 After 20 sec, want to start capturing the frame and produce it as an output. 20秒后,要开始捕获帧并将其作为输出。

Here you go: 干得好:

import cv2
import time

cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

fourcc = cv2.VideoWriter_fourcc(*'XVID')

videoout = cv2.VideoWriter("output.mkv", fourcc, cam.get(cv2.CAP_PROP_FPS), (1280, 720))

start = time.time()

while True:
    ret, frame = cam.read()
    if time.time() - start > 20:
        videoout.write(frame)

More information here . 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM