Skip to content

Instantly share code, notes, and snippets.

@peteruithoven
Created September 22, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peteruithoven/d4accdce6cd33796af8710749d346500 to your computer and use it in GitHub Desktop.
Save peteruithoven/d4accdce6cd33796af8710749d346500 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage examples:
#
# Create sd.mp4.gif
# $ gifenc sd.mp4
#
# Create sd.gif
# $ gifenc sd.mp4 sd.gif
#
# Create sd.mp4.gif from the 53.8 seconds point, 1.5 seconds long
# $ gifenc sd.mp4 sd.gif -ss 53.8 -t 1.5
palette="/tmp/palette.png"
filters="fps=15,scale=640:-1:flags=lanczos"
inputfile=${1?'supply input file name'}
outputfile=${2-$inputfile.gif}
echo "input: $inputfile"
echo "output: $outputfile"
echo "other arguments: ${@:3}"
ffmpeg -v warning $3 $4 -i "$inputfile" $5 $6 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning $3 $4 -i "$inputfile" -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" $5 $6 -y "$outputfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment