Skip to content

Instantly share code, notes, and snippets.

@arturschaefer
Created June 13, 2023 16:49
Show Gist options
  • Save arturschaefer/8bd2162cc2a3a2cb9ede8982416fa4d0 to your computer and use it in GitHub Desktop.
Save arturschaefer/8bd2162cc2a3a2cb9ede8982416fa4d0 to your computer and use it in GitHub Desktop.
Python script to convert WEBM to MP4
import sys
import subprocess
def convert_webm_to_mp4(filename):
try:
subprocess.run(["ffmpeg", "-i", filename, "-c:v", "libx264", "-c:a", "aac", "-b:a", "192k", "-strict", "experimental", "-f", "mp4", filename[:-5] + ".mp4"], check=True)
except subprocess.CalledProcessError as e:
print("Error:", e)
sys.exit(1)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python convert.py <filename.webm>")
sys.exit(1)
filename = sys.argv[1]
if not filename.endswith(".webm"):
print("Error: File must be a webm file.")
sys.exit(1)
convert_webm_to_mp4(filename)
print("Conversion complete.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment