Last active
September 9, 2024 03:18
-
-
Save Zamua/1dedf0ddc9dadc7c83e766b59fb221b9 to your computer and use it in GitHub Desktop.
use ffmpeg to convert a screen recording to a gif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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