Skip to content

Instantly share code, notes, and snippets.

@ailinykh
Last active August 28, 2017 15:46
Show Gist options
  • Save ailinykh/2bf10922a7aa2f48f208a491f9c3ff1c to your computer and use it in GitHub Desktop.
Save ailinykh/2bf10922a7aa2f48f208a491f9c3ff1c to your computer and use it in GitHub Desktop.
Bash script converts your videos into gif
#!/bin/bash
#
# Usage: ./video_to_gif.sh video.mp4
#
TARGET_FILE=$1
if [[ -z $TARGET_FILE ]]; then
echo "usage: video_to_gif.sh <target_file>"
echo "\ttarget_file - video file to convert into gif"
exit 1
fi
ffmpeg -y -i "${TARGET_FILE}" -vf fps=10,scale=480:-1:flags=lanczos,palettegen palette.png
ffmpeg -i "${TARGET_FILE}" -i palette.png -filter_complex "fps=10,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
rm palette.png
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment