Export & Codecs

GIF Into MP4: Convert It With FFmpeg or in Your Browser

GIF Into MP4: Convert It With FFmpeg or in Your Browser
Image: Vipid

To turn a GIF into an MP4, re-encode the animation as H.264 video with even pixel dimensions and a yuv420p pixel format. One FFmpeg command does it on your own machine, and a browser converter such as Ezgif, Convertio or CloudConvert does it with no install. The local route gives you control. The browser route gives you speed on a single clip.

This tutorial covers both routes for anyone searching for how to get a GIF into MP4 format. You will inspect the source file, run a first conversion, tune quality, fix timing, loop the clip to a target length, flatten transparency, add a silent audio track, and finish with a batch script for a whole folder. If your source is a phone recording rather than a GIF, the guide to converting iPhone video to MP4 without losing quality fits that case better.

Every vendor detail below comes from the tool’s own pages, read on November 26, 2026. Where a page did not state a limit, the article says so instead of guessing.

The one command that converts a GIF into an MP4

If you only want the answer, copy this line. It reads input.gif and writes output.mp4 in a format that plays in browsers, phones, editors and upload forms.

ffmpeg -i input.gif -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart output.mp4

Each part earns its place. libx264 is the H.264 encoder, which nearly every player and platform accepts. -crf 20 sets a visual quality target instead of a fixed bitrate. -pix_fmt yuv420p forces the pixel layout that QuickTime, Windows players and most phones expect. The scale filter rounds width and height down to even numbers, because H.264 in yuv420p cannot encode an odd size. -movflags +faststart moves the file index to the front so a browser can start playback before the whole file downloads.

That single command handles most animated GIF files. The rest of this guide covers the cases where it falls short: odd frame timing, short loops, transparent backgrounds, missing audio, and folders full of files.

One more point before the steps. The converted file will not look better than the GIF. The pixels inside a GIF are already dithered into a small palette, and the MP4 carries that dithering forward. What improves is file size, scrubbing in an editor, hardware playback and compatibility with upload forms that refuse GIF files.

What changes when a GIF becomes an MP4

A GIF and an MP4 are different kinds of object. A GIF is an image format that stores a list of indexed-color frames, each with its own delay, plus a flag that says whether to loop. An MP4 is a container that usually holds H.264 video, and it can hold audio, subtitles and metadata as well. Converting a GIF into MP4 therefore changes how the picture is stored, how time is stored and what the file can carry.

Illustrative: A hand holds a magnifying loupe over film strips on a lit light table
Photo: Jakub Zerdzicki / Pexels

The size gap comes from how each format compresses motion. A GIF compresses every frame on its own, with no memory of the frame before it. H.264 stores a full frame now and then and describes the changes in between, so a clip where only a small part moves costs far fewer bits. That is why a few seconds of screen recording can weigh several megabytes as a GIF and a fraction of that as video.

Here is what moves across, and what does not.

  • Picture: Frames are decoded and re-encoded as H.264, which stores differences between frames instead of whole images. Flat graphics and smooth gradients usually shrink the most.
  • Timing: A GIF stores a delay per frame in hundredths of a second. An MP4 normally runs at one constant frame rate, so FFmpeg has to map uneven delays onto a steady clock.
  • Looping: The GIF loop flag disappears. A player decides whether an MP4 loops, so you either loop it in the player or bake repeats into the file.
  • Transparency: A standard H.264 MP4 has no alpha channel. Transparent GIF areas must be filled with a background color during conversion.
  • Audio: GIFs have no sound. The MP4 will be silent unless you add a track, which some platforms expect.
  • Color: GIF colors are RGB. H.264 in yuv420p stores color at lower resolution than brightness, so thin colored lines on dark backgrounds can soften.

Keep that list in mind, because every problem in the troubleshooting section traces back to one of those six rows. Wrong speed is a timing problem. A black box around a sticker is a transparency problem. A file that will not play in QuickTime is a pixel format problem.

Prerequisites and versions

You need a terminal, FFmpeg with its companion tool ffprobe, and one GIF to practice on. According to the FFmpeg download page, the newest stable release on November 26, 2026 is FFmpeg 9.1 “Gauss”. The commands here use options that have existed in FFmpeg for years, so an older install works for nearly every step. The one exception is -fps_mode, which an old build may lack, so swap in -vsync cfr there if your build complains.

  • FFmpeg and ffprobe: 9.1 “Gauss” is the newest release per the FFmpeg site. Both programs ship in the same download and are free and open source.
  • A terminal: Terminal on macOS or Linux (Bash or zsh), or PowerShell on Windows.
  • A source GIF: Any animated GIF you have the right to reuse. A 3 to 5 second clip makes testing fast.
  • A video player: The default player on your system, plus VLC if you want a second opinion on compatibility.
  • Gifsicle (optional): Any current release. You need it for one troubleshooting fix only.
  • A browser: For the Ezgif, Convertio and CloudConvert steps.

Install FFmpeg with a package manager. Distribution repositories often trail the newest release by weeks or months, so check what you got with ffmpeg -version after installing.

# macOS (Homebrew)
brew install ffmpeg

# Windows (winget)
winget install Gyan.FFmpeg

# Debian and Ubuntu
sudo apt install ffmpeg

FFmpeg itself is a command-line toolkit, not a hosted service. The project’s own site lists no online converter and no paid plans, so any price you see on a GIF to MP4 website belongs to that website’s operator and not to FFmpeg.

Before you start, run through a short preflight. Keep the original GIF untouched in its own folder. Check the disk has room for a few test renders, which are small. Close any player that has the old output file open, because Windows will refuse to overwrite a file another program holds. Then make sure you know where the finished clip will go, since the destination decides the size, length and audio you need.

FFmpeg or a browser converter: which to use

Use FFmpeg when you need exact frame rate, size, loops or a batch. Use a browser converter when you have one file and no install. The table lists what each service says on its own pages as of November 26, 2026.

MethodPrice shown on its own pagesWhere the file is processedBatch or automationPick it when
FFmpeg command lineFree, open sourceYour machineAny folder, via a scriptYou want exact control or many files
Ezgif GIF to MP4 (standard)Free, per its Terms of Service dated November 18, 2026Uploaded to its serversUpload, convert, download on the pageYou have one clip and want it fast
Ezgif local processingFreeInside your browserLocal batch GIF to MP4 listed in its update notes dated November 18, 2026You would rather not upload the file
ConvertioFree conversions, 1 GB maximum file size in the upload box, with a sign-up link beside itUploaded. Uploads deleted instantly and converted files after 24 hours, per its pageUpload, convert, download on the pageYour GIF is large and you want a browser
CloudConvertPackages from €18.15 and subscriptions from €9.68 per month on its own siteUploadedAPI v2 with a Sandbox API for testingYou want conversion inside an automated pipeline

Ezgif’s Terms of Service name SIA Open Idea, registered in Riga, Latvia, as the operator and describe the site as a free media toolkit. The same page says it offers no paid or guaranteed public API. Its guidance, reportedly, is to use local tools such as FFmpeg, ImageMagick or Gifsicle for heavy batch work, which matches the advice in the table.

CloudConvert’s documentation confirms a Sandbox API where jobs do not consume credits. That is a testing environment, not a free conversion plan, so do not plan a workflow around it. The pricing pages did not show a free daily allowance in the material checked, so confirm that on the site before you depend on it.

Privacy tilts the choice for some creators. A client’s unreleased animation should not go to a third-party server if it does not have to. FFmpeg never leaves your machine, and Ezgif’s local processing mode keeps the work in your browser. Convertio’s page states how long it keeps files, which is useful to know, but it is still an upload.

Steps 1 to 4: inspect the GIF and run your first conversion

Step 1. Create a project folder. Keep source and output files together so paths stay short. Put your GIF inside and rename it input.gif so the commands below work as written.

Illustrative: Hands typing on a black and white mechanical keyboard in front of a screen showing code
Photo: Jakub Zerdzicki / Pexels
mkdir gif-to-mp4
cd gif-to-mp4
cp ~/Downloads/my-clip.gif input.gif

Step 2. Confirm FFmpeg works. Run both tools with the version flag. If either command fails, the install did not reach your PATH, so reopen the terminal or fix the install first.

ffmpeg -version
ffprobe -version

Step 3. Inspect the GIF. Read the size, frame rate and frame count before converting. This tells you whether the width and height are odd, whether the timing is steady and how long one pass lasts. The -count_frames flag makes ffprobe decode the file and count real frames, which GIFs need because they rarely store a frame count in the header.

ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=codec_name,width,height,r_frame_rate,avg_frame_rate,nb_read_frames,duration -of default=noprint_wrappers=1 input.gif

The output has this shape. The values below are an example for a small reaction clip, so yours will differ.

codec_name=gif
width=479
height=270
r_frame_rate=25/1
avg_frame_rate=25/1
duration=3.200000
nb_read_frames=80

Read it like a spec sheet. An odd width would crash a naive H.264 encode. A frame rate of 25 with 80 frames means one pass lasts 3.2 seconds. If r_frame_rate and avg_frame_rate differ a lot, the GIF has uneven delays, and Step 6 matters for you.

Step 4. Run the first conversion. Use the command from the top of the article. It writes output.mp4 and prints a progress line with frame count and speed.

ffmpeg -i input.gif -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart output.mp4

Open output.mp4 in two players. If it plays in both, you have a valid GIF into MP4 conversion and everything after this is tuning. If your GIF had an odd width, the output may be one pixel narrower or wider than the source, because the width has to be even. That one-pixel change is invisible in practice.

Steps 5 to 8: set quality, frame rate, loops and canvas size

Step 5. Pick a quality level. CRF is the quality dial in x264. Lower numbers keep more detail and make bigger files. A value near 23 is the encoder’s default, 18 is close to visually lossless for most content, and 28 is visibly soft. Render three versions and compare them by eye and by file size.

for crf in 18 23 28
do
  ffmpeg -v error -y -i input.gif -c:v libx264 -preset slow -crf $crf -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart test-crf$crf.mp4
done
ls -lh input.gif test-crf*.mp4

The listing prints one line per file. These sizes are illustrative, since the real ratio depends on how busy your GIF is.

-rw-r--r--  1 you  staff  6.8M  input.gif
-rw-r--r--  1 you  staff  410K  test-crf18.mp4
-rw-r--r--  1 you  staff  190K  test-crf23.mp4
-rw-r--r--  1 you  staff  105K  test-crf28.mp4

Photographic GIFs and screen recordings shrink a great deal. Flat two-color pixel art may shrink very little, and the MP4 can even come out larger at low CRF values. If that happens, raise the CRF or add -tune animation, covered in the advanced tips.

Step 6. Fix the frame rate. GIF delays are uneven in the wild. Some files use delays so short that browsers play them slower than the numbers imply, and many editors expect a constant rate. Force a steady rate with the fps filter. FFmpeg duplicates or drops frames as needed to hold the clock.

ffmpeg -i input.gif -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "fps=30,scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart steady.mp4

Choose 30 for general use, or match the rate ffprobe reported if the GIF was already steady. Do not set a higher rate than the source in the hope of smoother motion. Repeated frames cost bits and add nothing. FFmpeg’s GIF demuxer also exposes options for minimum and default frame delay and for honoring the loop count, all documented in the FFmpeg formats documentation. Reach for those only when a specific GIF plays at the wrong speed.

Step 7. Loop the clip to a target length. An MP4 has no loop flag, so repeat the frames inside the file when a platform or editor needs a longer clip. The -stream_loop input option sets how many extra passes to read, and -t cuts the output to a length in seconds.

# play the GIF 5 times in total (the first pass plus 4 repeats)
ffmpeg -stream_loop 4 -i input.gif -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "fps=30,scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart five-loops.mp4

# loop forever, then cut the output at exactly 12 seconds
ffmpeg -stream_loop -1 -i input.gif -t 12 -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "fps=30,scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart twelve-seconds.mp4

Place -stream_loop before -i. It is an input option, and FFmpeg ignores it silently if you put it after the input. The second form is the one to remember when a platform wants a clip of a specific length and your GIF runs 3.2 seconds.

Step 8. Fit the clip to a canvas. A small square GIF posted as a vertical video needs padding or a background. The filter chain below scales the GIF to fit inside the target frame without distortion, then centers it on a black canvas.

ffmpeg -stream_loop -1 -i input.gif -t 12 -vf "fps=30,scale=1080:1920:force_original_aspect_ratio=decrease:flags=lanczos,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1,format=yuv420p" -c:v libx264 -preset slow -crf 20 -movflags +faststart vertical.mp4

Scaling a small GIF up to fill a large canvas will look soft whichever scaling flag you pick. Letting it sit smaller on a clean background usually looks better than stretching it.

Steps 9 to 11: transparency, audio and the flags that matter

Step 9. Flatten transparency onto a background. A sticker or logo GIF with a transparent background converts to a black or garbled box if you ignore alpha. Generate a solid color source the same size as the GIF and lay the GIF over it. Use the width and height from Step 3, and match the frame rate to the GIF.

ffmpeg -i sticker.gif -f lavfi -i "color=c=0x1a1a1a:s=480x270:r=25" -filter_complex "[1:v][0:v]overlay=shortest=1:format=auto,fps=30,scale=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p" -c:v libx264 -crf 20 -movflags +faststart sticker.mp4

Here [1:v] is the color background and [0:v] is the GIF on top. The shortest=1 option stops the output when the GIF ends, because the color source would otherwise run forever. Pick a background that matches where the clip will sit. A dark gray reads well on most dark interfaces, and white suits slides and documents.

If you need real transparency in video, standard H.264 MP4 cannot carry it. You would need a different codec and container, which is a separate job from a plain GIF into MP4 conversion.

Step 10. Add an audio track when a platform needs one. Some upload forms and editors reject video with no audio stream. Generate silence with the anullsrc source and encode it as AAC. The -shortest flag ends the file when the video ends.

ffmpeg -i input.gif -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -shortest -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "fps=30,scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:a aac -b:a 128k -movflags +faststart with-audio.mp4

To add real music instead of silence, replace the anullsrc input with your audio file and map the streams by hand using -map 0:v -map 1:a. Keep -shortest so the longer track does not extend the clip. Only use music you have the right to publish, since a converted clip carries the same licensing duties as any other video.

Step 11. Learn the flags you will reuse. The table collects every option from the steps above. Nothing in it is specific to GIFs except the input, so the same flags work for any video you convert later.

FlagWhat it doesWhen to change it
-c:v libx264Encodes video as H.264Switch to libx265 only when your target supports HEVC
-crf 20Sets a constant quality targetLower for sharper, raise for smaller files
-preset slowTrades encode time for smaller filesUse fast for quick tests
-pix_fmt yuv420pForces the widely supported pixel layoutAlmost never, leave it on
scale=trunc(iw/2)*2:trunc(ih/2)*2Rounds width and height down to even numbersReplace with fixed values when you need a set size
-movflags +faststartPuts the index at the file startLeave on for anything played on the web
fps=30Holds a constant frame rateMatch the source rate when it is already steady
-stream_loop NRepeats the input N extra timesUse -1 with -t to loop to a length
-t 12Cuts output at 12 secondsSet to the length your platform wants

One related note on containers. Converting a MOV to MP4 can sometimes be a lossless remux that only changes the wrapper, as the article on converting MOV to MP4 explains. A GIF can never take that shortcut, because it holds images and not an H.264 stream, so every GIF conversion is a full re-encode.

Steps 12 and 13: convert a GIF into MP4 in your browser

Step 12. Use a browser converter when you have no install. The three services below share a basic flow. You upload the GIF, choose MP4, convert and download. They differ in limits, retention and what they let you adjust.

Ezgif GIF to MP4 converter page with a toolbar, a blue wireframe GIF preview, background color and loop settings
Image: Ezgif

Ezgif

Open the GIF to MP4 converter on ezgif.com, upload your file and press convert. The site reportedly states a 200 MB maximum upload and deletes server uploads after one hour. Ezgif has also added a local processing mode that runs in the browser. Its update notes dated November 18, 2026 list local batch GIF to MP4 conversion among the tools that gained it. Tick the local processing checkbox where a tool shows one, and the file stays on your computer.

The MP4 you get back is silent, because a GIF has no audio to carry over. If you need a track, add it afterward with Step 10. The service is free per its Terms of Service, which identify no paid tier.

Convertio

Convertio’s upload box states a 1 GB maximum file size, with a sign-up link beside it. Drop the GIF, set the output to MP4 and click convert. The site says it aims to finish conversions in under 1-2 minutes. Its own page states that it deletes uploaded files instantly and converted files after 24 hours. Download your MP4 promptly, because the converted file does not stay available beyond that window.

CloudConvert

CloudConvert suits people who want conversion inside a script or a no-code automation. Its API v2 is documented, and a Sandbox API lets you test jobs without spending credits. The site shows packages from €18.15 and subscriptions from €9.68 per month as of November 26, 2026. CloudConvert also offers a beta feature called Convert with AI. It is not needed for a GIF into MP4 job, so ignore it unless you are curious.

Step 13. Check the result no matter which route you used. Browser converters hide their settings, so verify the output the same way you inspected the input. This ffprobe call prints the codec, profile, pixel format, size, frame rate, duration and file size.

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile,pix_fmt,width,height,r_frame_rate:format=duration,size -of default=noprint_wrappers=1 output.mp4

A healthy result looks like the example below. Your numbers will differ, but the codec, profile and pixel format should match.

codec_name=h264
profile=High
pix_fmt=yuv420p
width=478
height=270
r_frame_rate=25/1
duration=3.200000
size=194311

If pix_fmt reads anything other than yuv420p, expect compatibility trouble in some players. Some converters pass the source layout through unchanged, so this check catches problems that look fine on your own screen.

Reading the filter chain: what each stage does to your GIF

The batch script and the transparency command use a longer chain than the one-liner, so it helps to see it laid out stage by stage. FFmpeg runs filters left to right, and the output of each feeds the next. Reading the chain in that order tells you where a problem enters.

[1:v][0:v]overlay=shortest=1:format=auto   # 1. lay the GIF over a solid color
fps=30                                      # 2. hold a constant frame rate
scale=trunc(iw/2)*2:trunc(ih/2)*2           # 3. round both sides down to even
format=yuv420p                              # 4. convert to the pixel layout players expect

Stage one flattens transparency. If the GIF has no transparent pixels, the overlay changes nothing, so it is safe to leave in a batch that mixes both kinds. Stage two fixes timing. Putting fps after the overlay means FFmpeg builds the constant-rate frames from the already flattened picture, which avoids odd blending at the edges of transparent shapes.

Stage three handles size. It must come before the final format conversion because chroma subsampling cares about the dimensions it is given. Stage four is the last change before encoding. Ending on format=yuv420p guarantees the encoder receives the layout you want, whatever the earlier stages produced.

Order matters more than it looks. Put scale before overlay and the background and GIF can end up different sizes. Put format=yuv420p before overlay and transparency may flatten to black. When a new problem appears, comment out one stage at a time until the output changes, and you will know which stage caused it.

Render settings for common GIF into MP4 jobs

Treat the table as a starting point, not a platform rule. Resolution, length and file size limits change, so read each platform’s current spec page before you upload. The values below are the settings used in this tutorial’s commands.

JobResolutionFrame rateLengthExport format
Reaction GIF reposted as videoSource size, rounded to evenMatch the sourceOne pass or a few loopsMP4, H.264, CRF 23
Website hero loopUp to 1280×720306 to 10 secondsMP4, H.264, CRF 20
Vertical social loop1080×192030Set by the platform, 12 seconds in the examplesMP4, H.264, silent AAC track
Logo sting for an editor timeline1920×108030Native length of the animationMP4, H.264, CRF 18
Slide deck embed1280×720305 seconds, looped by the deckMP4, H.264, yuv420p
Chat or forum uploadUnder the host’s size limitMatch the sourceShortMP4, H.264, CRF 28

When you need to know what resolution and frame rate a given intro style ships at, the Vipid intro themes page lists resolution, length and frame rate for each theme. That makes a handy reference for matching your converted loops to the clips around them.

From the Vipid archive: if your GIF is an animated logo sting, the animated logo intro theme starts from video, so you skip the GIF stage and its palette limits.

Complete working project: a batch GIF to MP4 script

This project converts every GIF in a folder with one command. It reads each file’s size, lays the GIF over a solid background to flatten any transparency, forces a steady frame rate, rounds to even dimensions, and writes a faststart H.264 MP4 to an output folder. Save it as gif2mp4.sh on macOS or Linux.

#!/usr/bin/env bash
set -euo pipefail

SRC_DIR="${1:-.}"
OUT_DIR="${2:-mp4-out}"
CRF="${CRF:-20}"
FPS="${FPS:-30}"
LOOPS="${LOOPS:-0}"
BG="${BG:-black}"

if [ -z "$(command -v ffmpeg)" ]
then
  echo "ffmpeg not found on PATH"
  exit 1
fi

mkdir -p "$OUT_DIR"
shopt -s nullglob
count=0

for gif in "$SRC_DIR"/*.gif "$SRC_DIR"/*.GIF
do
  name="$(basename "${gif%.*}")"
  size="$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "$gif")"
  out="$OUT_DIR/$name.mp4"
  echo "Converting $gif ($size)"
  ffmpeg -v error -y -stream_loop "$LOOPS" -i "$gif" \
    -f lavfi -i "color=c=$BG:s=$size:r=$FPS" \
    -filter_complex "[1:v][0:v]overlay=shortest=1:format=auto,fps=$FPS,scale=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p" \
    -c:v libx264 -preset slow -crf "$CRF" -movflags +faststart "$out"
  count=$((count + 1))
done

echo "Done: $count file(s) in $OUT_DIR"

Make it executable and run it. Environment variables override the defaults, so CRF=23 BG=white LOOPS=2 gives smaller files, a white background and three passes of each GIF.

chmod +x gif2mp4.sh
./gif2mp4.sh ./gifs ./mp4-out

# smaller files, white background, each GIF played three times
CRF=23 BG=white LOOPS=2 ./gif2mp4.sh ./gifs ./mp4-out

A run prints one line per file and a summary. This is the shape of the output for a folder holding two clips.

Converting ./gifs/logo-sting.gif (480x270)
Converting ./gifs/reaction.gif (320x240)
Done: 2 file(s) in ./mp4-out

Windows users can save the PowerShell version below as gif2mp4.ps1. It uses the same filter chain, so the output matches the Bash script.

param(
  [string]$Source = ".",
  [string]$Out = "mp4-out",
  [int]$Crf = 20,
  [int]$Fps = 30,
  [string]$Bg = "black"
)

New-Item -ItemType Directory -Force -Path $Out | Out-Null

Get-ChildItem -Path $Source -Filter *.gif | ForEach-Object {
  $size = ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 $_.FullName
  $target = Join-Path $Out ($_.BaseName + ".mp4")
  ffmpeg -v error -y -i $_.FullName -f lavfi -i "color=c=${Bg}:s=${size}:r=${Fps}" -filter_complex "[1:v][0:v]overlay=shortest=1:format=auto,fps=${Fps},scale=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p" -c:v libx264 -preset slow -crf $Crf -movflags +faststart $target
  Write-Host "Converted $($_.Name) to $target"
}

Run it with .\gif2mp4.ps1 -Source .\gifs -Out .\mp4-out -Crf 23. If PowerShell blocks the script, allow local scripts for your session with Set-ExecutionPolicy -Scope Process RemoteSigned and try again.

Finish by checking every output file with a loop around ffprobe. A short pass catches the occasional file that converted without error but ended up with the wrong pixel format.

for f in mp4-out/*.mp4
do
  echo "$f"
  ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,pix_fmt,width,height -of csv=p=0 "$f"
done

Each file should print h264,yuv420p followed by an even width and height. Anything else needs a second look. Keep the script in version control or a notes file with your usual CRF and background values, so the next batch matches the last one.

Common pitfalls when you convert a GIF to MP4

These six mistakes account for most failed conversions. Each takes a minute to avoid once you know it exists.

  1. Skipping the pixel format. Without -pix_fmt yuv420p, FFmpeg may keep a layout that plays in VLC but not in QuickTime, Windows Media Player or a phone gallery. The file looks fine on your machine and breaks for everyone else.
  2. Ignoring odd dimensions. A GIF with an odd width stops libx264 cold. Build the even-size scale filter into your default command so you never hit the error.
  3. Trusting the browser preview for speed. A GIF can look slower in a browser than it decodes in FFmpeg, because browsers treat very short delays differently. Judge speed from the ffprobe duration, not from how the GIF looked on a web page.
  4. Putting -stream_loop after the input. It is an input option. Placed after -i, it has no effect, and your clip stays one pass long.
  5. Upscaling a tiny GIF to fill a big canvas. A small GIF stretched far beyond its native size looks blurry and blocky. Keep it at native size on a background instead.
  6. Uploading sensitive files to a converter. Unreleased client work should go through FFmpeg or a local browser mode, not a server you do not control.

A seventh habit helps more than any flag. Always keep the original GIF. Re-encoding is a one-way trip for quality, and you may want a different size or loop length next month.

Troubleshooting: ten problems and their fixes

Match your symptom to the list. Each entry names the cause first, then the fix.

  1. Error “width not divisible by 2”. The GIF has an odd dimension. Add -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" to the command.
  2. The MP4 plays in VLC but not in QuickTime or on a phone. The pixel format is not yuv420p. Add -pix_fmt yuv420p and re-run, then confirm with the ffprobe check in Step 13.
  3. The clip plays too fast or too slow. The GIF has uneven or very short frame delays. Add fps=30 to the filter chain, and if one file still runs wrong, read the GIF demuxer delay options in the FFmpeg formats documentation.
  4. The MP4 stops after one pass. MP4 has no loop flag. Use -stream_loop before the input and -t for length, as in Step 7.
  5. A black box appears where the GIF was transparent. Alpha was dropped. Flatten onto a color with the overlay method in Step 9 and pick a background that fits the destination.
  6. Ghosting or trails behind moving objects. Some optimized GIFs store only the changed pixels between frames, and certain tools mishandle that. Unoptimize first with Gifsicle, then convert.
  7. The MP4 is larger than the GIF. The source is flat graphics or tiny, and your CRF is too low. Raise CRF to 26 or add -tune animation.
  8. Colors look washed out or shifted. The color matrix tag is missing or wrong. Add the BT.709 tags from the advanced tips.
  9. A platform rejects the upload. The cause is usually a missing audio track, the wrong size or too long a clip. Add silence with Step 10, then check the platform’s current spec page.
  10. An online converter fails or times out on a large GIF. You hit a size cap, such as Convertio’s 1 GB limit, or the job was too heavy. Convert locally with FFmpeg, which has no upload step.

For the Gifsicle fix in item 6, the command is short. It rewrites each frame as a full image, which removes the frame-difference tricks that confuse some decoders.

gifsicle --unoptimize input.gif -o input-full.gif
ffmpeg -i input-full.gif -c:v libx264 -crf 20 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -movflags +faststart fixed.mp4

If none of these fixes the problem, strip the command back to the minimum from the top of this article and add one flag at a time until the fault returns. That isolates the culprit faster than guessing.

Advanced tips for cleaner, smaller results

Tune for flat graphics. Cartoon art, logos and pixel art compress better with x264’s animation tuning. Add -tune animation next to -preset. It adjusts how the encoder treats sharp edges and flat areas, and it often shaves size without visible damage.

Tag the color space. If colors shift on playback, tell players which matrix the file uses. This chain converts with the BT.709 matrix and writes matching tags.

ffmpeg -i input.gif -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2:out_color_matrix=bt709,format=yuv420p" -colorspace bt709 -color_primaries bt709 -color_trc bt709 -c:v libx264 -crf 20 -movflags +faststart tagged.mp4

Smooth motion on slow GIFs. Many GIFs run at a low frame rate to keep file size down. The minterpolate filter synthesizes in-between frames and works on any FFmpeg build, though it runs slowly and can smear fast motion. FFmpeg 9.1 reportedly adds GPU frame interpolation, so check the release notes for your build if you convert many clips. Judge the result on a still-heavy and a motion-heavy clip before you commit to it for a batch.

ffmpeg -i input.gif -vf "minterpolate=fps=60,scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -crf 20 -pix_fmt yuv420p -movflags +faststart smooth.mp4

Make an HEVC version for Apple devices. When a smaller file matters and your audience uses recent Apple hardware, encode with -c:v libx265 -tag:v hvc1. The hvc1 tag is what lets QuickTime recognize the stream. The trade-off is compatibility, because H.264 plays almost everywhere and HEVC does not.

Remove duplicate frames. GIFs made from screen captures often repeat identical frames. The mpdecimate filter drops them, and pairing it with fps=30 restores a steady rate. This helps screencast GIFs most.

Use hardware encoders for large batches. If your machine has a GPU encoder, FFmpeg can use it by swapping libx264 for a hardware encoder such as h264_nvenc on Nvidia cards. Speed rises, but file size at a given quality is usually worse than x264, so stay with x264 for files you will keep.

Know the reverse trip. Going from MP4 back to GIF needs a palette pass with the palettegen and paletteuse filters, or a tool built for it. The conversion costs quality, so keep your MP4 master and generate GIFs from it only where a platform insists. For other ways to shrink video, see the guide on export settings and codecs.

Common questions

How do I turn a GIF into an MP4 for free?

Use FFmpeg, which is free and open source, or a free browser converter such as Ezgif. FFmpeg gives you full control and no upload. Ezgif’s Terms of Service describe the site as a free media toolkit, and Convertio’s upload page lists free conversions with a 1 GB file limit. Check each service’s current page before relying on a limit.

Does an MP4 made from a GIF have sound?

No. A GIF carries no audio, so the converted MP4 is silent. If a platform wants an audio track, add silence or music with the audio step in this tutorial.

Will the MP4 look better than the original GIF?

No. The MP4 inherits the GIF’s limited palette and dithering. What changes is the file size, the playback compatibility and the ease of editing. Converting does not recover detail that the GIF already lost.

Why does my GIF need even dimensions?

H.264 in the yuv420p layout stores color at half the horizontal and vertical resolution of brightness, so width and height must divide by two. An odd size breaks that rule. The scale filter in this guide rounds each side down to the nearest even number, which costs at most one pixel.

Is it safe to upload my GIF to an online converter?

It depends on the file. Convertio’s page says it deletes uploaded files instantly and converted files after 24 hours. Ezgif’s update notes dated November 18, 2026 describe a local processing mode that runs in your browser. For unreleased or client work, use FFmpeg or a local mode so the file never leaves your machine.

How do I make the MP4 loop?

An MP4 has no loop flag, so repeat the frames inside the file with -stream_loop and cut the length with -t. Most players and platforms also offer their own loop setting, which is the simpler route when it exists.

What is the best CRF value for a GIF into MP4?

Start at 20 and adjust. Values near 18 keep more detail, values near 23 match the encoder’s default balance, and values near 28 give small, softer files. Render three versions with the loop in Step 5 and pick by eye.

Can I convert a transparent GIF to a transparent MP4?

Not with a standard H.264 MP4, which has no alpha channel. Flatten the clip onto a background color as shown in Step 9, or choose a different codec and container built for alpha if your editor supports one.

More from the Vipid blog

Make it with Vipid

Jonah Reyes

Editing & Export Editor · Vipid Team

Jonah Reyes is the Editing & Export Editor at Vipid. He covers editing software, export settings and codecs, and the video specs of YouTube, Shorts, TikTok and Reels, plus OBS and screen recording. He builds Vipid’s spec tables from the platforms’ own documentation and re-checks them every 60 to 90 days, so the numbers in a guide match what the upload dialog actually accepts.

All articles by Jonah Reyes ›   How we check tools ›

Keep reading

AV1 vs HEVC [2026]: 30.6% Fewer Bits, 1 Vendor Test
Export & Codecs

AV1 vs HEVC [2026]: 30.6% Fewer Bits, 1 Vendor Test

Jonah Reyes·10 Nov 2026
AV1 vs H.264 [2026]: Smaller Files, 3 Conditions
Export & Codecs

AV1 vs H.264 [2026]: Smaller Files, 3 Conditions

Jonah Reyes·8 Nov 2026
Reduce Video File Size [2026]: 3 Codecs, 4 Tools
Export & Codecs

Reduce Video File Size [2026]: 3 Codecs, 4 Tools

Jonah Reyes·7 Nov 2026

Blog

Intros & Templates
Titles & Motion
Streaming
Editing & Export
AI Video

Vipid

About Vipid
Themes
News archive 2011–2016
Vipid Team

Editorial

Editorial policy
How we check tools
Corrections

Legal

Privacy policy
Terms of service
Making video intros since 2010.
The Vipid blog covers the tools behind them.