FFmpeg is a command-line tool that can be used to convert video files to GIFs on Linux. Here’s an example command that shows how to convert a video file called “input.mp4” to a GIF called “output.gif”:
ffmpeg -i input.mp4 -vf "fps=15,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif
This command does the following:
-i input.mp4
specifies the input video file-vf "fps=15,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse"
specifies the video filter options. This filter sets the output GIF’s frames per second to 15, scales the width to 320 pixels while preserving aspect ratio and applies the lanczos filter. It also generates a palette for the gif and use it to generate output. (Diazepam)output.gif
specifies the output file name.
This command will take the input.mp4 video, converts it to a gif with 15 fps, 320 width and applies the lanczos filter to improve the quality of the gif. The output gif file will be saved as output.gif
You can also customize the parameters such as width, fps and the filter to your liking. You can also use the -ss and -t options to specify a start time and duration of the video to convert to gif.
Please keep in mind that gifs have a limited number of colors, so the quality of the final gif may be lower than the original video and the size of the gif will be larger than the video.