import cv2def 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+1cv2.waitKey (1)vc. release ()for i in res_list_v:video_writer . write (i)