Skip to content

Instantly share code, notes, and snippets.

@Zamua
Last active September 9, 2024 03:18
Show Gist options
  • Select an option

  • Save Zamua/1dedf0ddc9dadc7c83e766b59fb221b9 to your computer and use it in GitHub Desktop.

Select an option

Save Zamua/1dedf0ddc9dadc7c83e766b59fb221b9 to your computer and use it in GitHub Desktop.
use ffmpeg to convert a screen recording to a gif
#!/bin/bash
# Check if FFmpeg is installed
if ! command -v ffmpeg &> /dev/null; then
echo "FFmpeg is not installed. Please install it first."
exit 1
fi
# Check if input file is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <input_file>"
exit 1
fi
input_file="$1"
output_file="${input_file%.*}.gif"
# Convert video to GIF
ffmpeg -i "$input_file" -vf "fps=10,scale=720:-1:flags=lanczos" -c:v gif "$output_file"
if [ $? -eq 0 ]; then
echo "Conversion complete. Output file: $output_file"
else
echo "Conversion failed."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment