Last active
October 18, 2016 16:32
-
-
Save NickShargan/49db479e30b21e005afb708004521c39 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
import os | |
import argparse | |
ap = argparse.ArgumentParser() | |
ap.add_argument("-i", "--input", required=True, help="path to dir with input videos") | |
ap.add_argument("-f", "--fps", type=int, default=5, help="FPS of output video") | |
args = vars(ap.parse_args()) | |
# Set your path for ring_dir | |
# ring_dir = "/Users/mykolasharhan/Data/ringcom/" | |
ring_dir = args["input"] | |
video_dir = ring_dir | |
frames_dir = "frames/" | |
if not os.path.exists(frames_dir): | |
os.makedirs(frames_dir) | |
video_names = os.listdir(video_dir) | |
target_fps = args["fps"] | |
for video_name in video_names: | |
if video_name[-4:] == '.mp4': | |
os.makedirs(frames_dir + video_name[:-4]) | |
command = "ffmpeg -i " + video_dir + video_name + " -r " +str(target_fps) + " " + frames_dir + video_name[:-4] + "/frame%04d.png" | |
os.system(command) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment