Skip to content

Instantly share code, notes, and snippets.

@PeskyPotato
Created June 24, 2019 08:54
Show Gist options
  • Save PeskyPotato/c9e05f7bb44dfd89a1b512499b684c0e to your computer and use it in GitHub Desktop.
Save PeskyPotato/c9e05f7bb44dfd89a1b512499b684c0e to your computer and use it in GitHub Desktop.
Bash script to make a gif from a section of a video using ffmpeg
#!/bin/bash
scale=640
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]
then
echo "Arugments <start time> <duration> <file>"
fi
ffmpeg -ss "$1" -t "$2" -y -i "$3" -vf fps=24,scale="$scale":-1:flags=lanczos,palettegen palette.png
ffmpeg -ss "$1" -t "$2" -i "$3" -i palette.png -filter_complex "fps=24,scale="$scale":-1:flags=lanczos[x];[x][1:v]paletteuse" out.gif
rm palette.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment