インストール
Python3とOpenCVをインストールします。
sudo yum install -y python3 sudo pip3 install opencv-python
動画を読み込んで、何もせず書き込む
import cv2
cap = cv2.VideoCapture('./img.MOV')
fps = cap.get(cv2.CAP_PROP_FPS)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
out = cv2.VideoWriter('output.m4v', fourcc, fps, (width, height))
while True:
ret, frame = cap.read()
if ret:
out.write(frame)
else:
break
cap.release()
out.release()
とりあえず、これでうまくいきました。縦横が逆になっていますが…