import subprocess from pathlib import Path print(""" Welcome to the FFMPEG H.265 Video Compressor This program will use 5mb bitrate This program will compress all videos in specified path This program will use GPU acceleration """) folderpath = input('Enter Folder path you want to compress: ') p = Path(folderpath) file_names = list(p.iterdir()) # Now we iterate through the file_names list we created print('Getting files located in', folderpath, '\n') print('===============================') file_names_str = [] for i in range(len(file_names)): print(file_names[i].name) file_names_str.append(file_names[i].name) print('===============================\n') continue_check = input('Type Y to continue:') if continue_check.lower() in ('y', 'yes'): print('success') outputfold = p / 'output' outputfold.mkdir(parents=True) # Output File Paths+Names file_output_names = [] for i in range(len(file_names)): path_temp = str(folderpath) + '\\output' + '\\' + file_names_str[i] file_output_names.append(path_temp) for i in range(len(file_names)): temp_name = file_names[i] temp_output_name = file_output_names[i] subprocess.run(["ffmpeg.exe", "-hwaccel", "cuvid", "-i", str(temp_name), "-pix_fmt", "p010le", "-c:v", "hevc_nvenc", "-preset", "slow", "-rc", "vbr_hq", "-b:v", "5M", "-maxrate:v", "10M", "-c:a", "aac", "-b:a", "240k", str(temp_output_name)], shell=True, check=True) else: print('Thank you for using this video converter') input('Press any key to exit')