import sys
import cv2
import os
video_dir = "videos"
video_list = os.listdir(video_dir)
codec = cv2.VideoWriter_fourcc(*'mp4v')
# video = cv2.VideoWriter(filepath, codec, CLIP_FPS, (w, h))
# encoder(for mp4)
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
# output file name, encoder, fps, size(fit to image size)
out_file_name = 'video.mp4'
video = cv2.VideoWriter(out_file_name,fourcc, 20.0, (1280, 720))
for frame in video_list:
# hoge0000.png, hoge0001.png,..., hoge0090.png
img = cv2.imread(os.path.join(video_dir,frame))
# can't read image, escape
if img is None:
print("can't read")
break
# add
video.write(img)
video.release()
print('written')
🐣
フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com
機械学習、ARアプリ(Web/iOS)を作っています。
機械学習/AR関連の情報を発信しています。