import os import subprocess from pathlib import Path def main(): input_path = input("Enter the path to your input video: ").strip().strip('"') output_folder = input("Enter the output folder path: ").strip().strip('"') input_file = Path(input_path) output_dir = Path(output_folder) if not input_file.exists(): print("❌ Input file does not exist.") return if not output_dir.exists(): print("⚠️ Output folder does not exist. Creating it.") output_dir.mkdir(parents=True, exist_ok=True) output_path = output_dir / "video.mp4" ffmpeg_cmd = [ "ffmpeg", "-i", str(input_file), "-c:v", "libx264", "-preset", "slow", # balance between speed and file size "-crf", "23", # quality (lower = better, ~18-28) "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", # for web streaming "-pix_fmt", "yuv420p", # widest compatibility str(output_path) ] print(f"🎬 Converting {input_file.name} → {output_path}") subprocess.run(ffmpeg_cmd) if output_path.exists(): print("✅ Conversion complete.") else: print("❌ Something went wrong during conversion.") if __name__ == "__main__": main()