Skip to content

Instantly share code, notes, and snippets.

@aphyr
Created March 28, 2018 04:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aphyr/fc385a6d57fd31a0c951d192b475753c to your computer and use it in GitHub Desktop.
Save aphyr/fc385a6d57fd31a0c951d192b475753c to your computer and use it in GitHub Desktop.
Video to gif script
#!/bin/bash
# Args: input video file, start time in HH:MM:SS, duration in seconds, output
# gif file.
# Tmpdir
rm -rf /tmp/video2gif
mkdir /tmp/video2gif
mplayer -nosub -ao null -ss "$2" -endpos "$3" "$1" -vo jpeg:outdir=/tmp/video2gif:quality=100
thunar /tmp/video2gif &
pid=$!
echo "Review frames and hit enter when ready."
read
kill -term $pid
echo "Converting to gifs"
ls /tmp/video2gif/*.jpg | parallel convert {} -resize 480x320 {}.gif
echo "Combining"
gifsicle -O3 --delay 6 --loop /tmp/video2gif/*.gif > "$4"
eog "$4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment