VSZM

URS Gaming Video Encoding

Mar 20th, 2020
117
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import subprocess
  3. from tqdm import tqdm_notebook as tqdm
  4.  
  5. ## Run the code in the Videos folder. The script looks for videos in subdirectories of current folder.
  6.  
  7. d = '.'
  8. video_dirs = [o for o in os.listdir(d) if os.path.isdir(os.path.join(d,o)) and o[0] != '.']
  9. video_dirs
  10.  
  11. for video_dir in tqdm(video_dirs, desc='Directories', position=0):
  12.     output_dir = 'Encoded ' + video_dir
  13.     os.mkdir(output_dir)
  14.     for video in tqdm(os.listdir(video_dir), desc=f'{video_dir} progress', position=1):
  15.         proc = subprocess.run(["ffmpeg", "-i", video_dir + '/' + video, '-c:v', 'h264_nvenc', '-b:v', '2M', '-bufsize', '2M',
  16.                         output_dir + '/' + video])
  17.         proc.check_returncode()
RAW Paste Data Copied