Skip to content

Instantly share code, notes, and snippets.

@explodi
Last active June 22, 2018 17:37
Show Gist options
  • Save explodi/f5639acc2519945e41348448b0bf67d6 to your computer and use it in GitHub Desktop.
Save explodi/f5639acc2519945e41348448b0bf67d6 to your computer and use it in GitHub Desktop.
hi5
#!/bin/bash
# based on https://gist.github.com/yellowled/1439610
# on mac, to install ffmpeg, use this: brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
IN=$1
OUT=$(echo $1 | sed 's/^\(.*\)\.[a-zA-Z0-9]*$/\1/')
# webm
ffmpeg -i $IN -f webm -vcodec libvpx -an -ab 128000 -b:v 1M $OUT.webm
# mp4
ffmpeg -i $IN -an -strict experimental -ac 2 -ab 128k -vcodec libx264 -f mp4 $OUT.mp4
# ogg (if you want to support older Firefox)
# ffmpeg2theora $IN -o $OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
# gif
ffmpeg -y -i $IN -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png
# ffmpeg -i $IN -pix_fmt rgb24 -vf scale=640:-1 $OUT.gif
ffmpeg -i $IN -i palette.png -filter_complex "fps=10,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" $OUT.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment