How to Convert MP4 to an Animated GIF
Turn an MP4 clip into an animated GIF: trim the clip, choose frame rate and size, build a color palette, then check file size, looping and quality.
Converting an MP4 video into an animated GIF is useful for short loops, reactions, tutorials and previews that need to play without a video player. A GIF has no audio and is limited to 256 colors per frame. Its file is usually much larger than the source MP4 for the same clip length. Good results come from choosing a short segment, a modest frame rate and a sensible width before you convert.
Before you start
Decide where the conversion will run. A desktop tool such as FFmpeg processes the file locally on your computer. A browser-based converter usually uploads the video to the provider's server. If the clip shows people, screens or anything private, read that service's privacy and file retention terms before uploading. Do not assume files are deleted automatically.
- The MP4 file, plus a copy kept as a backup so the original is never overwritten.
- The start time and length of the part you want, ideally only a few seconds.
- The target width in pixels, based on where the GIF will be shown.
- For the local method: FFmpeg installed and available from a terminal or command prompt. Running ffmpeg -version should print version information.
Step-by-step instructions
The steps below use FFmpeg because it works the same way on Windows, macOS and Linux. Run the commands in the folder that contains your video, and replace input.mp4 and output.gif with your own file names. Each command writes a new file and leaves the source video untouched.
1. Run a quick basic conversion
To convert the whole video with default settings, run: ffmpeg -i input.mp4 output.gif. This is fine for testing, but the default palette often causes visible banding. Full-length or high-resolution clips can also produce very large files.
2. Trim the clip
Add -ss for the start time and -t for the duration, both in seconds or in hh:mm:ss format. For example, ffmpeg -ss 5 -t 3 -i input.mp4 output.gif converts three seconds starting at the five-second mark. Shorter clips are the most effective way to keep a GIF small.
3. Set frame rate and size
Use the fps filter to lower the frame rate and the scale filter to set the width. The value -1 keeps the original aspect ratio. Example: ffmpeg -ss 5 -t 3 -i input.mp4 -vf "fps=12,scale=480:-1:flags=lanczos" output.gif. A lower frame rate and a smaller width both reduce file size, at the cost of smoothness and detail.
4. Generate a custom palette for better color
Because a GIF can store only 256 colors per frame, FFmpeg can build a palette from your clip and then apply it. Example: ffmpeg -ss 5 -t 3 -i input.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif. The -loop 0 option makes the animation repeat indefinitely. Use -loop -1 instead if it should play only once.
5. Using an online converter or editor instead
Browser converters and video or image editors expose the same core choices under different names. Look for start and end time, frame rate, output width or size, and looping. Labels and menu locations differ between tools and versions, so check the tool's own help pages rather than relying on a fixed path.
Check the output
- Open the GIF in a web browser or image viewer and confirm it animates, starts and ends where you intended, and loops as expected.
- Check the file size in your file manager and compare it with any upload limit of the site or app where you plan to post it.
- Run ffprobe output.gif to confirm the dimensions and frame rate match your settings.
- Look closely at gradients, skin tones and dark areas, where the 256-color limit is most visible as banding or dotted dithering.
- Remember that the GIF contains no sound, even if the MP4 had an audio track.
Some platforms convert uploaded GIFs into video formats for playback. What viewers see may therefore differ from your file. Check the platform's own documentation if exact appearance matters.
Common problems and next steps
The GIF is too large
Shorten the clip first, then lower the width, then reduce the frame rate, for example from 15 to 10. Cropping to the important area with the crop filter also helps. If the destination accepts video or animated WebP, consider using those formats, since they are usually far more efficient than GIF for the same clip.
Colors look banded or noisy
Use the palettegen and paletteuse method from step 4 instead of the basic conversion. You can change the dithering pattern, for example paletteuse=dither=bayer:bayer_scale=5, and compare the results. Footage with smooth gradients will always show some compromise in GIF.
Motion looks choppy
Raise the fps value moderately and accept a larger file, or keep the frame rate and shorten the clip to stay within your size limit.
The animation does not loop
Add -loop 0 to the command and convert again. Some apps and viewers apply their own playback rules regardless of the file setting, so test in the place where the GIF will actually be used.
The ffmpeg command is not recognized
This usually means FFmpeg is not installed or its folder is not in your system PATH. Reinstall it following the instructions for your operating system, open a new terminal window, and run ffmpeg -version again before retrying the conversion.