-
Notifications
You must be signed in to change notification settings - Fork 27
/
convertFPS.py
21 lines (17 loc) · 1.01 KB
/
convertFPS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import argparse
import os
import subprocess
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-i", "--input-folder", type=str, help='Path to folder that contains video files')
parser.add_argument("-fps", type=float, help='Target FPS', default=25.0)
parser.add_argument("-o", "--output-folder", type=str, help='Path to output folder')
args = parser.parse_args()
os.makedirs(args.output_folder, exist_ok=True)
fileList = []
for root, dirnames, filenames in os.walk(args.input_folder):
for filename in filenames:
if os.path.splitext(filename)[1] == '.mp4' or os.path.splitext(filename)[1] == '.mpg' or os.path.splitext(filename)[1] == '.mov' or os.path.splitext(filename)[1] == '.flv':
fileList.append(os.path.join(root, filename))
for file in fileList:
subprocess.run("ffmpeg -i {} -r 25 -y {}".format(file, os.path.splitext(file.replace(args.input_folder, args.output_folder))[0]+".mp4"), shell=True)