Adds video2gif

This commit is contained in:
Thomas Forgione 2019-07-11 15:08:19 +02:00
parent 74348830db
commit 6a22736160
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 21 additions and 0 deletions

21
bin/video2gif Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
if [ $# -ne 3 ]; then
echo -e "\033[31;1merror:\033[0m this script expects three arguments, the file, the starting time and the duration."
exit 1
fi
if [ ! -f $1 ]; then
echo -e "\033[31;1merror:\033[0m couldn't open $1: no such file."
exit
fi
palette_dir=$(mktemp -d)
ffmpeg -y -ss $2 -t $3 -i $1 \
-vf fps=10,scale=320:-1:flags=lanczos,palettegen $palette_dir/palette.png > /dev/null 2>&1
ffmpeg -ss $2 -t $3 -i $1 -i $palette_dir/palette.png -filter_complex \
"fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" -y output.gif > /dev/null 2>&1
rm -rf $palette_dir