1、avi 视频转换为 MP4格式文件
import datetime
import time
import cv2
import os
cam = cv2.VideoCapture('video/video2/myvideol2.avi') #输入.AVI数据
time_now =time.time()
# fourcc = cv2.VideoWriter_fourcc(*'avc1')
os.makedirs('capture', exist_ok=True)
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
video_out = None
while True:
ret, frame = cam.read()
if video_out:
video_out.write(frame)
cv2.imshow("asdf", frame)
cv2.waitKey(1)
if video_out is None or time.time() - time_now > 10:
if video_out:
# print("save", video_path)
video_out.release()
video_out = None
timestr = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
video_path = timestr + '.mp4'
video_out = cv2.VideoWriter(video_path, fourcc, 30.0, (640, 480))
time_now = time.time()
<