Skip to content

Instantly share code, notes, and snippets.

@iamdey
Created September 5, 2016 08:11
Show Gist options
  • Select an option

  • Save iamdey/c1227e79145c137999f6fb784bdb811f to your computer and use it in GitHub Desktop.

Select an option

Save iamdey/c1227e79145c137999f6fb784bdb811f to your computer and use it in GitHub Desktop.
convert ogv to gif (requires ffmpeg)
#!/bin/bash
# from Dawid Drozd http://unix.stackexchange.com/a/298656/187922
inputFile=$1
[ -z $2 ] && outputFile=output.gif || outputFile=$2
FPS=15
WIDTH=640
CMD=ffmpeg
PALETTE_PATH=/tmp/ogv-to-gif_palette.png
#Generate palette for better quality
$CMD -i $inputFile -vf fps=$FPS,scale=$WIDTH:-1:flags=lanczos,palettegen $PALETTE_PATH
#Generate gif using palette
$CMD -i $inputFile -i $PALETTE_PATH -loop 0 -filter_complex "fps=$FPS,scale=$WIDTH:-1:flags=lanczos[x];[x][1:v]paletteuse" $outputFile
rm $PALETTE_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment