Skip to main content

Convert an animated GIF to an MP4 with ffmpeg

I sometimes need to convert animated GIFs into MP4 movie files – this can often result in much smaller files, which is useful for serving the images on the web.

This is the ffmpeg command I use:

ffmpeg \
  -i INPUT_GIF_PATH \
  -movflags faststart \
  -pix_fmt yuv420p \
  [-vf scale=WIDTH:HEIGHT] \
  [-y] \
  OUTPUT_MP4_PATH

Here’s what it’s doing: