opencv读写

# coding:utf-8
import cv2, os, sys
import numpy as np

'''
XSQ_20190130155258_20190130174000.mp4 [[0,420],[1920,360]]
'''
video_name = 'XSQ_20190130155258_20190130174000.mp4'
video_path = './XSQ/'+video_name
save_video_path = './mask/'+video_name
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print("video not open")
sys.exit(-1)

fps = cap.get(cv2.CAP_PROP_FPS)
size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
foucc = cap.get(cv2.CAP_PROP_FOURCC)

writer = cv2.VideoWriter(save_video_path, cv2.VideoWriter_fourcc(*'MP4V'), fps, size)
idx = 0
while True:
ret, frame = cap.read()
if ret:
writer.write(frame)
# print(idx)
# idx += 1
else:
break

 

posted @ 2019-02-14 14:19  O1dCat  阅读(131)  评论(0编辑  收藏  举报