First, ensure that you have installed FFmpeg. If not installed, you can download the version suitable for your operating system from the FFmpeg official website.
The basic command to generate GIF is straightforward. First, open your command-line tool (CMD or PowerShell on Windows, Terminal on Mac or Linux), then use the following command format:
bashffmpeg -i input.avi output.gif
Here, input.avi is the name of the AVI file you want to convert, and output.gif is the name of the output GIF file.
Example:
Assume you have a video file named example.avi and you want to convert it to example.gif. You can use the following command:
bashffmpeg -i example.avi example.gif
Advanced Options:
-
Control GIF Quality and Size: Use the
scalefilter to adjust the image size, which helps control the size and quality of the output GIF. For example, scale the video to a width of 320 pixels:bashffmpeg -i input.avi -vf "scale=320:-1" output.gifHere,
-1indicates that the height will be automatically adjusted to maintain the original aspect ratio of the video. -
Set Frame Rate: Too high a frame rate can result in a large GIF file, while too low a frame rate may make the animation appear less smooth. Use the
-rparameter to specify the frame rate:bashffmpeg -i input.avi -vf "fps=10,scale=320:-1" output.gifHere,
fps=10means 10 frames per second. -
Crop Video: If you only want to generate a GIF from a specific part of the video, use the
-ss(start time) and-t(duration) options:bashffmpeg -i input.avi -ss 00:00:05 -t 3 -vf "scale=320:-1" output.gifThis will create a GIF starting from the 5th second and lasting for 3 seconds.
By combining these basic and advanced options, you can flexibly generate GIF files that meet your requirements.