Last active
December 5, 2023 11:03
-
-
Save hipertracker/695ff1ebdd58a8ea463c67da65d292e2 to your computer and use it in GitHub Desktop.
Convert mpg4 into h264 file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert mpg4 into h264 file. | |
src: https://gist.github.com/hipertracker/695ff1ebdd58a8ea463c67da65d292e2 | |
""" | |
import os | |
import sys | |
from moviepy.editor import VideoFileClip | |
if len(sys.argv) != 2: | |
print("You must specify the source mpg file path") | |
raise SystemExit(2) | |
filepath = sys.argv[1] | |
if not os.path.exists(filepath): | |
print(f"File {filepath} not found") | |
raise SystemExit(2) | |
name, _ = os.path.splitext(filepath) | |
out = f"{name}-out.mp4" | |
VideoFileClip(filepath).write_videofile(out, codec="libx264", logger="bar") | |
# usage: mpg2mp4.py <mpg file path> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment