spacepaste

  1.  
  2. import subprocess
  3. from pathlib import Path
  4. print("""
  5. Welcome to the FFMPEG H.265 Video Compressor
  6. This program will use 5mb bitrate
  7. This program will compress all videos in specified path
  8. This program will use GPU acceleration
  9. """)
  10. folderpath = input('Enter Folder path you want to compress: ')
  11. p = Path(folderpath)
  12. file_names = list(p.iterdir())
  13. # Now we iterate through the file_names list we created
  14. print('Getting files located in', folderpath, '\n')
  15. print('===============================')
  16. file_names_str = []
  17. for i in range(len(file_names)):
  18. print(file_names[i].name)
  19. file_names_str.append(file_names[i].name)
  20. print('===============================\n')
  21. continue_check = input('Type Y to continue:')
  22. if continue_check.lower() in ('y', 'yes'):
  23. print('success')
  24. outputfold = p / 'output'
  25. outputfold.mkdir(parents=True)
  26. # Output File Paths+Names
  27. file_output_names = []
  28. for i in range(len(file_names)):
  29. path_temp = str(folderpath) + '\\output' + '\\' + file_names_str[i]
  30. file_output_names.append(path_temp)
  31. for i in range(len(file_names)):
  32. temp_name = file_names[i]
  33. temp_output_name = file_output_names[i]
  34. 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)
  35. else:
  36. print('Thank you for using this video converter')
  37. input('Press any key to exit')
  38.