All Articles

Using FFmpeg to Convert a MOV Viedo to a GIF Image

movie-gif

FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. It’s a powerful tool for professionals and enthusiasts.

FFmpeg can decode a file of its supported formats and reencode it. This feature could be used to convert file formats. Furthermore, FFmpeg supports for various filters enhances its utility in refining the output. Filters such as ‘scale’, ‘fps’, and ‘palettegen’ can integrated into the conversion process, allowing users to manipulate the dimensions, frame rate, and color palette.

A practical implementation of FFmpeg for converting a MOV video to a GIF image can be elucidated through the provided code snippet. Command line could be,

$ ffmpeg -i input.mov -pix_fmt rgb8 -r 10 output.gif

The example code take RGB8 as the output codec (-pix_fmt rgb8), and set frame rate to 10 Hz (-r 10) to reduce size. As -f is not specified, the ffmpeg binary will guess the format on file extension, so the output will be automatically set to GIF image in the example.

Published Dec 20, 2023

Flying code monkey