Skip to content

Instantly share code, notes, and snippets.

@burgil
Last active April 22, 2024 00:45
Show Gist options
  • Save burgil/406b1959a0ad802e615801031835c73d to your computer and use it in GitHub Desktop.
Save burgil/406b1959a0ad802e615801031835c73d to your computer and use it in GitHub Desktop.
Flawlessly compress MOV file to MP4 for faster web streaming (I just compressed 158MB with it to just 12MB in less than two minutes and I compared between the two, the new file actually looks better and much less glitchy)
import subprocess
def compress_mov_to_mp4_ffmpeg(input_file, output_file, bitrate='1000k'):
command = ['ffmpeg', '-i', input_file, '-b:v', bitrate, output_file]
subprocess.call(command)
# Example usage
compress_mov_to_mp4_ffmpeg('input.mov', 'output.mp4')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MP4 Video preload example</title>
<link rel="preload" href="SEO-Friendly-Name.mp4" as="video" type="video/mp4" />
</head>
<body>
<video controls>
<source src="SEO-Friendly-Name.mp4" type="video/mp4" />
<!-- Optionally load a webm when possible: -->
<!-- <source src="SEO-Friendly-Name.webm" type="video/webm" /> -->
<p>
Your browser doesn't support HTML video. Here is a
<a href="SEO-Friendly-Name.mp4">link to the video</a> instead.
</p>
</video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment