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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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

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
I have posted a question for the same at unix.stackexchange.com/questions/274352/… . Kindly have a look. :-) – We are Borg Apr 5 at 7:50

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

Your Answer


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