How to convert AVI to MP4
Step-by-step ffmpeg commands that turn old AVI files into MP4s that play in any browser. They range from a lossless remux that takes seconds to a full re-encode with deinterlacing.
Install the free FFmpeg tool. Most AVI files need a re-encode to H.264 video and AAC audio: ffmpeg -i input.avi -c:v libx264 -crf 20 -preset medium -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart output.mp4. If the AVI already holds a codec MP4 allows, a stream copy works in seconds with no loss: ffmpeg -i input.avi -c copy -movflags +faststart output.mp4.
Somewhere on most hard drives is a folder of AVI files. They might be camcorder tapes captured in the 2000s, screen recordings from an old tool, or a wedding video someone burned to a disc. They play in VLC, refuse to play in a browser, and are too big to email. Converting them to MP4 solves all three problems. With FFmpeg it costs nothing but a little processor time.
This guide gives the exact commands and explains what each option does. It also covers the two problems AVI files bring more often than any other format: packed B-frames and interlaced video. It ends with a batch loop and a checklist to run before you upload the results or archive them. If you are not sure AVI is your problem at all, the video formats hub explains containers and codecs from the start.
Remux or transcode?
There are two ways to turn an AVI into an MP4. A remux copies the compressed video and audio streams unchanged into the new container. It is lossless and takes a few seconds. A transcode decodes the streams and encodes them again with a new codec. It takes minutes and is lossy. But it is the only option when MP4 does not allow the codec inside the AVI, or browsers cannot play it. The container vs codec explainer covers the distinction in depth.
In practice most AVI files need a transcode. The common AVI codecs are DV, Motion JPEG, uncompressed RGB, and MPEG-4 Part 2 (DivX and Xvid). Only the last is legal in MP4, and even it has patchy browser support, so re-encoding to H.264 is the reliable path. The first step is therefore to find out what you have.
Step by step
Every command below runs in a terminal on macOS, Linux or Windows. Replace the file names with your own; quote them if they contain spaces.
Install FFmpeg
On macOS with Homebrew:
brew install ffmpeg. On Debian or Ubuntu:sudo apt install ffmpeg. On Windows, download a build from the links on ffmpeg.org and add its bin folder to your PATH. Confirm withffmpeg -version.Inspect the AVI
Run
ffprobe -hide_banner input.aviand note four things. First, the video codec, for examplempeg4,dvvideo,mjpegorrawvideo. Second, the audio codec, such asmp3,pcm_s16leorac3. Third, the resolution and frame rate. Last, whether the video is interlaced: look fortfforbffin the field order.Try a remux if the codecs allow it
If ffprobe shows
mpeg4orh264video withmp3oraacaudio, a stream copy may work:ffmpeg -i input.avi -c copy -movflags +faststart output.mp4. If ffmpeg complains about packed B-frames, add a bitstream filter:ffmpeg -i input.avi -c copy -bsf:v mpeg4_unpack_bframes -movflags +faststart output.mp4.Otherwise, transcode to H.264 and AAC
The general-purpose command:
ffmpeg -i input.avi -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart output.mp4. CRF 20 is a good quality target for archive copies. Raise it toward 23 for smaller files.-pix_fmt yuv420pensures the output uses the chroma format every player supports, which matters for AVIs holding RGB or 4:2:2 video.Deinterlace if the source is interlaced
DV camcorder footage is almost always interlaced. Add the yadif filter before encoding:
ffmpeg -i input.avi -vf yadif -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart output.mp4. Skipping this leaves comb-like lines on motion in every progressive player and browser.Check the result
Run
ffprobe -hide_banner output.mp4and confirmh264andaac, the expected resolution and duration. Open the file in a browser directly to confirm it starts playing immediately, which proves the faststart flag worked.
What the options mean
| Option | Meaning | When to change it |
|---|---|---|
-c copy | Copy all streams without re-encoding | Only when the codecs are MP4-legal and browser-playable |
-c:v libx264 | Encode video with the x264 H.264 encoder | Use libx265 or libsvtav1 only if the target players support them |
-preset medium | Speed/efficiency trade-off; slower presets give smaller files at the same quality | slow for archives, veryfast for quick previews |
-crf 20 | Constant quality; lower is better and larger (18-23 is the useful range) | 18 for near-transparent, 23 for smaller files |
-pix_fmt yuv420p | Force 8-bit 4:2:0 chroma for universal playback | Leave it on unless you know the target supports 4:2:2 or 10-bit |
-c:a aac -b:a 160k | Encode audio as AAC at 160 kbps | 128k for speech, 192k-256k for music |
-movflags +faststart | Move the index to the front so playback starts before download finishes | Always keep it for web delivery |
-vf yadif | Deinterlace | Only for interlaced sources; harmless to omit for progressive |
-vf scale=-2:720 | Resize to 720 pixels tall, width auto and even | Downscaling old SD footage is rarely needed; upscaling never helps |
Handling the awkward cases
Some AVIs carry audio as uncompressed PCM at 48 kHz, which is fine to convert to AAC as above. Others carry AC-3, which MP4 permits but browsers mostly refuse. The AAC line handles that too. If an AVI has two audio tracks and you want both, add -map 0 before the codec options. Then ffmpeg keeps every stream instead of picking one of each type.
Variable frame rate AVIs, usually from screen recorders, can produce out-of-sync audio after conversion. Adding -vsync cfr (or -fps_mode cfr on recent FFmpeg versions) with an explicit -r 30 forces a constant frame rate that keeps sound and picture aligned. Corrupt indexes, common in files recovered from failing discs, are often repaired simply by transcoding, because ffmpeg rebuilds the timing from the stream itself.
Frame rate itself is worth a moment's thought. PAL DV runs at 25 frames per second and NTSC DV at 29.97. Leave those as they are. Converting between them creates judder for no benefit, as the frame rate guide explains.
Batch conversion
For a folder of files, a shell loop applies the same command to each one.
- macOS or Linux:
for f in *.avi; do ffmpeg -i "$f" -vf yadif -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart "${f%.avi}.mp4"; done - Windows Command Prompt:
for %f in (*.avi) do ffmpeg -i "%f" -vf yadif -c:v libx264 -preset medium -crf 20 -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart "%~nf.mp4" - Drop
-vf yadiffrom the loop if the sources are progressive; deinterlacing progressive video wastes time and can soften the image slightly. - Add
-nafterffmpegto skip files whose output already exists, which makes an interrupted batch safe to restart.
Before you upload or archive
- Confirm each MP4 plays from the first second in a browser. Any delay suggests the faststart flag was missing.
- Spot-check a scene with fast motion for combing (interlacing left in) or ghosting (deinterlacing applied to progressive video).
- Compare file sizes to what you expect. A one-hour SD H.264 file at CRF 20 usually lands well under a gigabyte. A 4 GB output means something is wrong with the settings.
- Keep the AVI until the MP4 has been checked. It is the source of truth, even if it is ten times the size.
- Upload the finished MP4. Files up to 4 GB use resumable uploads, as the help page on resuming an interrupted upload explains. The large file guide covers what to expect.
Frequently asked questions
Will converting AVI to MP4 reduce quality?
A remux with -c copy is lossless. A transcode to H.264 is lossy in principle. But at CRF 18-20 the loss is invisible for standard-definition camcorder or screen-recording sources, and the MP4 is usually far smaller. The AVI codecs themselves, such as DV and MPEG-4 Part 2, are already lossy. So the conversion is not harming a perfect master. Keep the AVI if you want a bit-for-bit original.
Can I convert AVI to MP4 without installing anything?
If the goal is online playback, upload the AVI straight to VideoBB. The platform accepts AVI files up to 4 GB and transcodes them into HLS renditions automatically. For a local MP4 file you need a converter. The free VideoBB video converter works from your browser with a free account, so there is nothing to install. FFmpeg is the free, scriptable standard that most desktop converters wrap. HandBrake is a friendlier option that uses the same x264 encoder.
Why does the converted video look fuzzy compared to the original?
Either the CRF value was too high, the source was interlaced and not deinterlaced, or you are comparing on a screen much larger than the original resolution. Standard-definition AVI footage is 720 by 576 or 720 by 480 pixels and will always look soft on a 4K monitor. Do not upscale; it adds size without adding detail. Lower the CRF to 18 if fine textures are visibly worse.
How long does conversion take?
It depends on the preset, the resolution and the processor. Standard-definition footage with the medium preset typically encodes several times faster than real time on a modern laptop, so an hour of tape takes minutes. The slow preset roughly doubles the time for a modest file-size gain. Hardware encoders such as VideoToolbox or NVENC are faster still but produce larger files.
Sources
- FFmpeg documentation: ffmpeg — Command-line syntax and stream mapping
- FFmpeg formats documentation — The mov/mp4 muxer and movflags options
- FFmpeg filters documentation — yadif and scale filters
- FFmpeg H.264 encoding guide — CRF and preset guidance for libx264
Related guides

MP4 vs MKV vs AVI
Three containers from three different decades. Here is what each one can hold, where it plays, what it cannot do, and why MP4 is the right default for anything you upload or share.

Container vs codec
A file extension names the wrapper. The codec is the compression inside it. Confusing the two is the root of most playback failures, and telling them apart takes one command.

Prepare video for upload
The right export is smaller, uploads faster, is accepted without complaint and transcodes cleanly. It is not the highest possible quality and it is not the smallest file. Here is the middle.

How to upload 2 GB video files
Large uploads fail for boring reasons: a sleeping laptop, a flaky Wi-Fi hop, a file that was never going to be accepted. Here is how to get a big file up in one go, and what to do when it stops.