Skip to content

Instantly share code, notes, and snippets.

@octipus
Last active April 22, 2022 11:49
Show Gist options
  • Save octipus/b9acb7707d5f6f2090d1c6fa069b31dd to your computer and use it in GitHub Desktop.
Save octipus/b9acb7707d5f6f2090d1c6fa069b31dd to your computer and use it in GitHub Desktop.
ffmpeg Single/Batch compression script
### Single File - default compressor - change the CRF value to tweak with size(and quality)
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
### Single FIle - webm compressor
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1M target.webm
###Single File - webm compressor - losless compression
ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
ffmpeg -i input.mp4 -b:v 0 -crf 30 -pass 2 output.webm
### Batch Compression
1. Create a new folder for all your videos
2. Inside, create another folder called: compressed
3. Run script via your CLI in your initial folder
4. optional - change the CRF value to tweak with size(and quality)
for %a in ("*.*") do (ffmpeg -i "%a" -vcodec libx265 -crf 28 "compressed\%~na.mp4")
pause
### USEFUL FLAGS - can be used on any othe the above scripts
-an - remove audio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment