#!/bin/bash # # gifit - Convert videos into GIFs with ffmpeg # Copyright © 2019-2021 Keith Irwin www.ki9.us # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Variables scale="${2:-600}" # Width in pixels (default 600) fps="${3:-20}" # Frames per second (default 20) filters="fps=$fps,scale=$scale:-1:flags=lanczos[x];[x]split[x1][x2]; [x1]palettegen[p];[x2][p]paletteuse" echo "$filters" outname="${1%.*}.gif" # Name for output # Check for arguments if [ $# -lt 1 ] || [ $# -gt 3 ]; then echo "USAGE: $0 filename [fps] [scale]" exit 1 fi # Do the conversion ffmpeg -i "$1" -filter_complex "$filters" "$outname"