This is the way I found to create high quality GIFs from videos. Feel free to recommend a better path or tool.
- Install ffmpeg. Make sure ffplay is installed along with ffmpeg.
For example for macOS:
brew install ffmpeg --with-ffplay
- If the original video has black bars at the top/bottom, you can remove them:
- Detect the values for the cropping filter using ffplay. The cropdetect filter is configured with the arguments
cropdetect=limit:round:reset,24:16:0is the default.ffplay -i video.mp4 -vf "cropdetect=24:16:0" # At the end of each line from the output you will find the values for the cropping filter. E.g. crop=1280:656:0:72
- Let's crop using the cropping filter values.
ffmpeg -i video.mp4 -vf crop=1280:656:0:72 -c:a copy video_cropped.mp4
- Detect the values for the cropping filter using ffplay. The cropdetect filter is configured with the arguments
- Use this script to convert your video into GIF.
videotogif.sh input.mp4 output.gif
Works with other formats as .mov too