Last active
June 14, 2019 13:57
-
-
Save pokabu55/eea547335eb762c24e434d34da1d3ff7 to your computer and use it in GitHub Desktop.
指定のディレクトリから、指定の拡張子の画像データを並べて動画を作成します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 所定のディレクトリの画像から、動画を作るサンプルコード | |
import cv2 | |
import glob | |
# 保存先のディレクトリからファイル名を取得 | |
fileName = glob.glob("./picture/*.jpg") | |
# 念の為、ソート | |
fileName.sort() | |
# コーデックの種類 | |
codecs = 'H264' | |
# fps、雲の流れる速度が変わるので、そこそこ重要かも | |
fps = 15 | |
# 動画のサイズ | |
imgW = 1280 | |
imgH = 960 | |
fourcc = cv2.VideoWriter_fourcc(*codecs) | |
# 保存ファイル名とパラメータの指定 | |
video = cv2.VideoWriter('timeLapseSky_20fps_full.mp4', fourcc, fps, (imgW, imgH)) | |
for fn in fileName: | |
print(fn) | |
img = cv2.imread(fn) | |
img = cv2.resize(img, (imgW, imgH)) | |
video.write(img) | |
video.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment