The DivX and XviD Legacy
DivX and XviD dominated video sharing in the early 2000s. If you have a hard drive full of movies from that era — 700 MB files sized to fit on a single CD-R — they are almost certainly encoded with one of these codecs and wrapped in an AVI container.
Both DivX and XviD implement the MPEG-4 Part 2 Advanced Simple Profile (ASP) standard, but they come from very different origins. DivX started as a proprietary commercial codec, while XviD (literally "DivX" spelled backwards) was an open-source response built from the same MPEG-4 ASP spec. In practice, any player that handles one can handle the other.
The problem today is that MPEG-4 Part 2 has been superseded by H.264 (MPEG-4 Part 10) and H.265 (HEVC). Modern browsers, smartphones, and smart TVs offer limited or no support for DivX/XviD playback. Converting to MP4 with H.264 video ensures your files play everywhere while maintaining or even improving visual quality at the same file size.
Identifying Your Files
DivX and XviD files typically come as .avi or .divx files. Before converting, check the actual codec:
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,width,height \
-of csv=p=0 input.avi
Common results:
| Codec Name | What It Means |
|---|---|
mpeg4 | MPEG-4 Part 2 (DivX 4/5/6 or XviD) |
msmpeg4v3 | DivX 3 (older, lower quality) |
h264 | Already H.264 in AVI — just remux |
If you see h264, you can skip re-encoding entirely and remux from AVI to MP4 with -c copy.
Converting DivX/XviD to MP4
Since MPEG-4 Part 2 is not natively supported in the MP4 container (technically it is, but player support is poor), re-encoding to H.264 is the recommended approach.
Standard Conversion
ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow \
-c:a aac -b:a 128k -movflags +faststart output.mp4
A CRF of 19 is recommended for DivX/XviD sources because the original content is already lossy and moderately compressed. Going lower (e.g., CRF 16) wastes space preserving compression artifacts from the source, while going higher (e.g., CRF 24) may introduce visible degradation.
Preserving Original Resolution
DivX-era content was typically encoded at standard definition resolutions:
| Common Resolution | Aspect Ratio | Era |
|---|---|---|
| 640x480 | 4:3 | DVD rips (fullscreen) |
| 720x480 | 4:3 or 16:9 | DVD rips (NTSC) |
| 640x352 / 640x272 | ~16:9 / 2.35:1 | Widescreen movie rips |
| 320x240 | 4:3 | Early internet video |
Do not upscale these files during conversion. Converting a 640x480 source to 1080p just wastes space without adding detail. Let FFmpeg preserve the original resolution by omitting any -s or -vf scale flags.
Handling MP3 Audio in AVI
DivX/XviD files almost always use MP3 audio. While FFmpeg can convert this to AAC for the MP4 container, the audio is already lossy — re-encoding introduces generational loss:
# Option 1: Re-encode to AAC (most compatible)
ffmpeg -i input.avi -c:v libx264 -crf 19 -c:a aac -b:a 160k output.mp4
# Option 2: Copy MP3 audio directly into MP4 (avoids re-encoding)
ffmpeg -i input.avi -c:v libx264 -crf 19 -c:a copy output.mp4
Option 2 is technically valid — MP3 audio in MP4 containers works in most modern players — and avoids any audio quality loss.
Handling Subtitles
DivX-era files typically have subtitles as separate .srt files (not embedded). To include them in the MP4:
Soft Subtitles (Togglable)
ffmpeg -i input.avi -i subtitles.srt \
-c:v libx264 -crf 19 -c:a aac -b:a 128k \
-c:s mov_text -movflags +faststart output.mp4
Hard Subtitles (Burned In)
ffmpeg -i input.avi -vf "subtitles=subtitles.srt" \
-c:v libx264 -crf 19 -c:a aac -b:a 128k output.mp4
For more on subtitle handling, see our guide on how to add subtitles to video.
Batch Converting a DivX Collection
If you have a large library of DivX/XviD files, batch convert them:
mkdir -p converted
for file in *.avi *.divx; do
[ -f "$file" ] || continue
output="converted/$(basename "${file%.*}.mp4")"
ffmpeg -i "$file" -c:v libx264 -crf 19 -preset medium \
-c:a aac -b:a 128k -movflags +faststart "$output" -y
done
For large collections, the medium preset balances speed and compression efficiency. The slow preset gives 5-10% better compression but takes roughly twice as long.
Online Conversion
Skip the command line and use the AVI to MP4 converter online. Upload your DivX or XviD file and get a clean MP4 back. For other output formats, try the Video Converter.
Quality and Settings Tips
CRF selection for DivX/XviD sources: Since the source is already lossy, there is no point in using an extremely low CRF. The sweet spot is CRF 18-20 for archival and CRF 22-24 for sharing. Going below CRF 16 just preserves MPEG-4 ASP blocking artifacts at inflated file sizes.
File size comparison: A 700 MB DivX file (the classic CD-R size) typically converts to 400-600 MB in H.264 at equivalent visual quality. H.264 is significantly more efficient than MPEG-4 Part 2 — you get the same quality in less space, or better quality in the same space.
Pixel aspect ratio: Some DVD-sourced DivX files use non-square pixels (anamorphic encoding). FFmpeg handles this automatically by reading the PAR from the source, but verify the output looks correct. If the image appears stretched, add -vf "setsar=1" to force square pixels.
For a deeper dive into video codecs, read our video codecs explained guide.
Common Issues and Troubleshooting
"Discarding AVI packed B-frames"
XviD files encoded with "packed bitstreams" produce this warning. It is harmless — FFmpeg handles it correctly. The output will play fine.
Green or corrupted frames
Some very old DivX 3 files use a non-standard codec variant. If you see corruption, try forcing the decoder:
ffmpeg -c:v mpeg4 -i input.avi -c:v libx264 -crf 19 output.mp4
Out-of-sync audio
DivX files with VBR (Variable Bit Rate) MP3 audio can develop sync drift. Fix with:
ffmpeg -i input.avi -c:v libx264 -crf 19 \
-c:a aac -b:a 128k -async 1 output.mp4
Missing codec error on older files
DivX 3 (from 1998-1999) uses the msmpeg4v3 codec, which requires the mpeg4 decoder in FFmpeg. This should work out of the box with any modern FFmpeg build. If you encounter issues, update to the latest FFmpeg version.
Conclusion
DivX and XviD files are a product of their era — impressively efficient for 2002, but outclassed by H.264 today. Converting them to MP4 with H.264 encoding gives you universal playback compatibility and often reduces file size by 30-40% at the same visual quality. The process is straightforward: re-encode the video with libx264 at CRF 19, copy or re-encode the audio, and optionally include subtitles.
Ready to convert? Try our free AVI to MP4 converter — no registration required.



