Last active
May 7, 2017 18:58
-
-
Save Nattefrost/2aa311795ac95cbaa451542816a6626a to your computer and use it in GitHub Desktop.
convert_to_16_9
This file contains hidden or 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
# requires ffmpeg | |
# possible CLI argument -r to remove files from input_dir | |
import os | |
from colorama import * | |
import time | |
import argparse | |
YELLOW = Fore.YELLOW | |
CYAN = Fore.CYAN | |
RED = Fore.RED | |
DEFAULT = Fore.RESET | |
# path to ffmpeg.exe directory | |
ffmpeg = r'C:/Program Files/ffmpeg/bin/' | |
# directory with videos you want to transform | |
input_dir = r"C:/Users/nattefrost/Videos/gaming/conversion/" | |
output_dir = r"C:/Users/nattefrost/Videos/gaming/out" | |
# new resolution | |
new_height = '720' | |
new_width = '1280' | |
videos = os.listdir(input_dir) | |
os.chdir(ffmpeg) | |
def resize_videos(remove_vids): | |
for vid in videos: | |
command = """ {0} -loglevel warning -i {1}/{2} -s {3}x{4} -c:a copy {5}/{2} """.format('ffmpeg.exe', input_dir, vid, new_width, new_height, output_dir, vid) | |
print(YELLOW + "Processing {0}... ".format(vid) + DEFAULT) | |
os.system(command) | |
print(RED + "{0} DONE".format(vid) + DEFAULT) | |
if remove_vids: | |
os.remove("{0}{1}".format(input_dir, vid)) | |
def choose_montage(): | |
vids_list = os.listdir(output_dir) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description="Converts videos to desired resolution") | |
parser.add_argument('-r','--remove', action='store_true', help="Removes files from input_dir after they've been processed", required = False) | |
parser.add_argument('-m','--montage', action='store_true', help="Lets you concatenate videos in the order of your choice", required = False) | |
args = vars(parser.parse_args()) | |
remove = True if args['remove'] else False | |
make_montage = True if args['montage'] else False | |
resize_videos(remove) | |
#if make_montage: | |
#choose_montage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment