Files
gif2webm/gif2webm.sh
2026-03-17 09:37:09 +01:00

29 lines
834 B
Bash
Executable File

#!/bin/bash
# Display usage information when requested or when no arguments are provided
usage() {
echo "Usage: $0 input.gif [speedup_factor]"
echo " speedup_factor: Factor by which to speed up the animation (default is 1)."
echo " -h or --h: Display this help message."
exit 1
}
# Check if help is requested
if [[ $1 == "-h" || $1 == "--h" ]]; then
usage
fi
# Validate parameters
if [[ $# -lt 1 ]]; then
usage
fi
input_file="$1"
speedup="${2:-1}" # Default to 1 if not provided
output_file="${input_file%.gif}.webm"
# Run ffmpeg command with the specified parameters
ffmpeg -i "$input_file" -vf "scale=512:512:force_original_aspect_ratio=decrease,fps=30,setpts=${speedup}*PTS" -pix_fmt yuva420p -b:v 512k "$output_file"
echo "Converted $input_file to $output_file with a speedup factor of $speedup."