Last active
April 6, 2022 14:51
-
-
Save jesuslg123/aa1ccac7c1722b35936e41735d30f53d to your computer and use it in GitHub Desktop.
Runcam 4K(XV) to 4K 4:3
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 subprocess | |
import glob | |
def delete_file(file_path): | |
print('removing: ' + file_path) | |
subprocess.call(['rm', file_path]) | |
def create_folder(name): | |
print('creating folder: ' + name) | |
subprocess.call(['mkdir', name]) | |
def clean_duplicated_frames(file_path): | |
print('cleaning duplicatede frames: ' + file_path) | |
subprocess.call(['ffmpeg', | |
'-i', file_path, | |
# '-c:v', 'h264_nvenc', | |
'-b:v', '50M', | |
'-vf', 'mpdecimate=hi=64:lo=32:frac=0.1,setpts=N/FRAME_RATE/TB', | |
'processed/{0}_clean.mp4'.format(file_path)]) | |
def change_aspect(file_path): | |
print('fixing aspect ratio: ' + file_path) | |
subprocess.call(['ffmpeg', | |
'-i', 'processed/{0}_clean.mp4'.format(file_path), | |
'-c:v', 'h264_nvenc', | |
'-b:v', '50M', | |
'-vcodec', 'copy', | |
'-aspect', '4:3', | |
'processed/{0}_4_3.mp4'.format(file_path)]) | |
delete_file('processed/{0}_clean.mp4'.format(file_path)) | |
files_path = glob.glob("*.MP4") + glob.glob('*.mp4') | |
create_folder('processed') | |
for file in files_path: | |
print(file) | |
clean_duplicated_frames(file) | |
change_aspect(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment