Skip to content

Instantly share code, notes, and snippets.

@sueharaluke
Last active December 20, 2024 12:58
Show Gist options
  • Save sueharaluke/f6105c6fd841d2d65f48bf29900197df to your computer and use it in GitHub Desktop.
Save sueharaluke/f6105c6fd841d2d65f48bf29900197df to your computer and use it in GitHub Desktop.
Convert video to mp4 or webm using ffmpeg

Convert to mp4

ffmpeg -i original.mp4 -vcodec libx264 -crf 24 converted.mp4

ffmpeg -i original.mov -vcodec libx264 -crf 24 converted.mp4

Convert to webm

ffmpeg -i original.mp4 -vcodec libvpx -qmin 0 -qmax 50 -crf 10 -b:v 1M converted.webm

ffmpeg -i original.mov -vcodec libvpx -qmin 0 -qmax 50 -crf 10 -b:v 1M converted.webm

Batch all files inside directory

for file in *.mp4; do ffmpeg -i "$file" -vcodec libvpx -qmin 0 -qmax 50 -crf 10 -b:v 1M "${file%.mp4}.webm"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment