Turn any video into a clean, smooth GIF with a single bash command.
ffmpegandffprobeavailable inPATH.- Bash shell (script tested with
bash).
Check first:
ffmpeg -version && ffprobe -versionIf both commands work, you are set. Otherwise:
- macOS:
brew install ffmpeg(Homebrew). Without Homebrew, download a macOS build from evermeet.cx or gyan.dev and placeffmpeg/ffprobesomewhere on yourPATH(e.g.,/usr/local/binor/opt/homebrew/bin). - Windows: Download the "release full" zip from gyan.dev (FFmpeg builds), unzip to
C:\\ffmpeg, and addC:\\ffmpeg\\binto yourPATH. Open a new terminal afterward. - Linux:
- Debian/Ubuntu:
sudo apt-get update && sudo apt-get install ffmpeg - Fedora/RHEL/CentOS:
sudo dnf install ffmpeg(orsudo yum install ffmpegon older releases) - Arch:
sudo pacman -S ffmpeg
- Debian/Ubuntu:
After installing, re-run ffmpeg -version and ffprobe -version to confirm.
Optional: run scripts/check_ffmpeg.sh to see whether both tools are available and get OS-specific guidance.
./video_to_gif.sh /path/to/video.mp4 [output.gif]- If
output.gifis omitted, the script saves next to the input using the same base name (e.g.,video.mp4→video.gif). - The script will exit if the input file does not exist or ffmpeg/ffprobe are missing.
Convert clips/dance.mov to a GIF in the same folder:
./video_to_gif.sh clips/dance.mov
# Creates: clips/dance.gifConvert and specify a custom output path:
./video_to_gif.sh clips/dance.mov ~/Desktop/dance_small.gif- Detects the exact frame rate of the source video to keep motion smooth.
- Generates an optimized color palette, then applies it for cleaner GIF output.
- Uses Lanczos scaling; width is preserved and height auto-adjusts to maintain aspect ratio.
- Trim your video before conversion for smaller GIFs.
- For very large inputs, consider resizing first in your video editor to reduce file size.