mpeg2mp4.py (763B)
1 import os 2 import subprocess 3 4 def convert_mpeg_to_mp4(): 5 input_dir = r"E:\Pictures\他人作品\ホロ\sukumiz" 6 extension = ".mpeg" 7 8 files = [f for f in os.listdir(input_dir) if f.lower().endswith(extension)] 9 10 for file in files: 11 input_path = os.path.join(input_dir, file) 12 output_path = os.path.join(input_dir, os.path.splitext(file)[0] + ".mp4") 13 14 command = [ 15 "ffmpeg", 16 "-i", input_path, 17 "-c:v", "hevc_nvenc", 18 output_path 19 ] 20 21 try: 22 subprocess.run(command, check=True) 23 except subprocess.CalledProcessError as e: 24 print(f"Error converting {file}: {e}") 25 26 if __name__ == "__main__": 27 convert_mpeg_to_mp4()