VideoBB
Upload Premium Sign in

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.

Abstract illustration of a weathered tape reel transforming into a smooth glowing rectangle along a flowing path

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.

  1. 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 with ffmpeg -version.

  2. Inspect the AVI

    Run ffprobe -hide_banner input.avi and note four things. First, the video codec, for example mpeg4, dvvideo, mjpeg or rawvideo. Second, the audio codec, such as mp3, pcm_s16le or ac3. Third, the resolution and frame rate. Last, whether the video is interlaced: look for tff or bff in the field order.

  3. Try a remux if the codecs allow it

    If ffprobe shows mpeg4 or h264 video with mp3 or aac audio, 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.

  4. 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 yuv420p ensures the output uses the chroma format every player supports, which matters for AVIs holding RGB or 4:2:2 video.

  5. 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.

  6. Check the result

    Run ffprobe -hide_banner output.mp4 and confirm h264 and aac, 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

OptionMeaningWhen to change it
-c copyCopy all streams without re-encodingOnly when the codecs are MP4-legal and browser-playable
-c:v libx264Encode video with the x264 H.264 encoderUse libx265 or libsvtav1 only if the target players support them
-preset mediumSpeed/efficiency trade-off; slower presets give smaller files at the same qualityslow for archives, veryfast for quick previews
-crf 20Constant quality; lower is better and larger (18-23 is the useful range)18 for near-transparent, 23 for smaller files
-pix_fmt yuv420pForce 8-bit 4:2:0 chroma for universal playbackLeave it on unless you know the target supports 4:2:2 or 10-bit
-c:a aac -b:a 160kEncode audio as AAC at 160 kbps128k for speech, 192k-256k for music
-movflags +faststartMove the index to the front so playback starts before download finishesAlways keep it for web delivery
-vf yadifDeinterlaceOnly for interlaced sources; harmless to omit for progressive
-vf scale=-2:720Resize to 720 pixels tall, width auto and evenDownscaling 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.

  1. 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
  2. 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"
  3. Drop -vf yadif from the loop if the sources are progressive; deinterlacing progressive video wastes time and can soften the image slightly.
  4. Add -n after ffmpeg to 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

avi to mp4ffmpegvideo conversionh264deinterlacing

Related guides