zl程序教程

您现在的位置是:首页 >  后端

当前栏目

opencv-python 视频处理之时光倒流

PythonOpencv 处理 视频
2023-09-14 09:14:34 时间
import cv2
def main_dao() :
    vc = cv2. VideoCapture ('sample.mp4')
    c=1
    #获得视频的帧率
    fps = vc.get (cv2.CAP_PROP_FPS)
    fourcc = cv2. VideoWriter_fourcc(* 'MJPG' )
    video_writer = cv2 .VideoWriter ("timereflux .mp4", fourcc, fps ,(640, 480) )
    res_list_v=[]#倒叙的帧列表
    while vc.isOpened() :
        rval, frame = vc. read ()
        if c>=21 and c<=60:
            res_list_v.insert(0,frame)
            # cv2. imwrite('image/' + str(60-c) + '.jpg', frame)
            c=c+1
        cv2.waitKey (1)
    vc. release ()
    for i in res_list_v:
        video_writer . write (i)