Convert animated gif to mp4

Solution 1:

You can use two programs, Imagemagick's convert command and ffmpeg, to do this.

convert -coalesce animation.gif frames%04d.png

Then convert the pngs to a movie:

ffmpeg -r 10 -i frames%04d.png -vcodec mjpeg -y movie.mp4

For a GUI, it would not gain you much convenience, but I know QuickTime Pro (you might have to get the old version) will convert a stack of sequential images into an animation. I don't know if it will read the GIF properly.

Solution 2:

Beroe's answer was really helpful but I found that when I created mp4s using his method it didn't work on QT or iMovie on El Capitan. I did a little digging and read the encoding logs and stumbled upon this solution, seems to work with QT and iMovie:

ffmpeg -r 10 -i frames%04d.jpg -vcodec h264 -y -pix_fmt yuv420p movie.mp4

Solution 3:

Despite using Mavericks, I still keep Quicktime 7 Pro Player on my disk. It is just fine for viewing animated GIFs and exporting them in other formats.

added

Requires Quicktime 7 (optional install, or keep it in your Applications when you install new versions of the OS). Requires the paid "Pro" upgrade key, Quicktime 7 version available since 2005 or so.

Open the GIF file with Quicktime Player 7. (Drag the GIF icon onto the Player icon; or right-click the GIF icon and choose Quicktime Player 7 under "Open with"; or start Quicktime Player 7, then use Open File... in theFile menu)

Play it to make sure it is working. You can use the left and right arrow keys to go forward or back one frame at a time.

Window > Show Movie Inspector (or ⌘-I). Write down the "Normal size", 270 x 600 or whatever it is

inspector

File > Export (or ⌘-E)

In the Export: menu choose Movie to MPEG-4 (or some other format if you wish)

export

Use the Options button to control some characteristics of the MP4 file. In particular, set the Image size (if the size you wrote down isn't in the menu, choose Custom and write it in). Try format MPEG-4 Improved. Click OK when you are finished with options.

options

Select the destination and filename for the MP4 file

Click Save