import argparse
parser = argparse.ArgumentParser() parser.add_argument('-i','-I','--input', help='Input vedio file') parser.add_argument('-o','-U','--output', default = "out_test.avi", help='Output vedio file, default as "out_test.avi"')
args = parser.parse_args() INPUT = args.input OUTPUT = args.output
import cv2 import numpy as np
cap = cv2.VideoCapture(INPUT) fps_c = cap.get(cv2.CAP_PROP_FPS) Vedio_h = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) Vedio_w = cap.get(cv2.CAP_PROP_FRAME_WIDTH) print("Current fps:",fps_c)
fps_o = fps_c Out_size = (int(Vedio_w),int(Vedio_h)) fourcc = cv2.VideoWriter_fourcc('M','J','P','G') videowriter = cv2.VideoWriter(OUTPUT,fourcc,fps_o,Out_size)
List= [] while True: ret,frame=cap.read() try: frame[0,0,0] != None List += [frame] except: break
for i in List[::-1]: videowriter.write(i)
videowriter.release()
|