Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What command would I use to convert an mp4 or mv4 video file to an animated gif, and vice versa. That is, convert a animated gif to a mp4 or mv4.

share|improve this question

migrated from stackoverflow.com Jun 12 '12 at 21:11

This question came from our site for professional and enthusiast programmers.

3 Answers 3

In my case, using ffmpeg directly did the trick and provided the best result:

$ ffmpeg -f gif -i infile.gif outfile.mp4
share|improve this answer

You should be able to use imagemagick and ffmpeg. This Stackoverflow post explains how to do it and includes links to additional resources.

Note: the title of the post says .avi, but the accepted answer outputs mpeg.

share|improve this answer
Please provide some of the answer here instead of just linking. –  Naftuli Tzvi Kay Sep 10 '13 at 2:35

Another way to convert GIF animation to video:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.mp4

-crf values can go from 4 to 63. Lower values mean better quality. -b:v is the maximum allowed bitrate. Higher means better quality.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.