Skip to content

Instantly share code, notes, and snippets.

@koveseb
Last active December 31, 2021 11:41
Show Gist options
  • Save koveseb/b77db17f77bbe48e72067c15ffa4efea to your computer and use it in GitHub Desktop.
Save koveseb/b77db17f77bbe48e72067c15ffa4efea to your computer and use it in GitHub Desktop.
Compress mp4 video for web
# Output as muted mp4
ffmpeg -i source.mp4 -an -vcodec copy output-min.mp4
# Very slow compress
ffmpeg -i input.avi -c:v libx264 -crf 18 -preset veryslow -c:a copy out.mp4
# Output as webm
ffmpeg -i source.mp4 -c:v libvpx-vp9 -b:v 1M -pass 1 -f webm /dev/null && ffmpeg -i source.mp4 -c:v libvpx-vp9 -b:v 1M -pass 2 output.webm
# Mute video
ffmpeg -i source-mute.mp4 -acodec copy -vcodec copy -movflags faststart output-mute-fast.mp4
# Compress the muted video even more
ffmpeg -i source-mute-fast.mp4 -vcodec libx264 -crf 28 output-mute-fast-h265.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment