January 23, 2020

Convert MP4 or mov to gif in linux using the command line

How to convert movie mp4 or mov files to gif in linux using ffmpeg

Convert MP4 or mov to gif in linux using the command line

Converting a movie file like .mp4 or .mov is easy in Linux using ffmpeg. You may find this is already installed on your system.

To convert a file use the following format:

ffmpeg -i video_to_format.mp4 -pix_fmt rgb24 outputname.gif

To convert a file starting at a specific time you can specify the -ss flag. To end converting at a specific time use the -t time stamp as shown below:

ffmpeg -ss 00:00:00.000 -i video_to_format.mp4 -pix_fmt rgb24  -t 00:00:10.000 outputname.gif

The size of this video will probably be quite big, you can adjust the resolution by adding the -s flag as such

ffmpeg -ss 00:00:00.000 -i video_to_format.mp4 -pix_fmt rgb24 -s 800x600 -t 00:00:10.000 outputname.gif