FFmpeg - Encode MPEG-4 Part 2
FFmpeg supports two primary ways to encode MPEG‑4 Part 2 video: using the external Xvid library (libxvid) or FFmpeg’s native mpeg4 encoder. Both produce broadly compatible MPEG‑4 Part 2 output, but they differ in dependency requirements, performance characteristics, and quality at lower bitrates.
Context
MPEG‑4 Part 2 is used in legacy and AVI-based workflows. FFmpeg supports it through libxvid and the native mpeg4 encoder.
Encoding Options
Using libxvid
ffmpeg -i input.avi -c:v libxvid output.avi
Using native mpeg4
ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi
FourCC
Use -vtag to override the default FMP4 FourCC, for example: -vtag xvid.
Quality Notes
libxvid generally produces better output at low bitrates, particularly around ~1000 kbit/s for 720p.
Practical Examples
High-quality Xvid
ffmpeg -i input.mp4 -c:v libxvid -qscale:v 3 -c:a libmp3lame -qscale:a 3 output.avi
Native MPEG4 with Xvid FourCC
ffmpeg -i input.mp4 -c:v mpeg4 -vtag xvid -b:v 1500k -c:a mp2 output.avi