FFmpeg - Encode MPEG-4 Part 2

From PiRho Knowledgebase
Revision as of 14:35, 14 March 2026 by Dex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

FFmpeg provides two primary ways to encode MPEG‑4 Part 2 video: the external libxvid library and FFmpeg’s native mpeg4 encoder. Both generate broadly compatible MPEG‑4 Part 2 output suitable for AVI‑based and legacy workflows. This article explains the differences, when to use each option, how to control FourCC behaviour, and practical examples.

Context

MPEG‑4 Part 2 (sometimes simply “MPEG‑4 Visual”) is an older but still widely supported video compression standard. It remains relevant for:

  • Legacy systems and appliances
  • AVI‑based delivery pipelines
  • Devices that pre‑date widespread H.264 adoption
  • Archival scenarios where compatibility is more important than efficiency

FFmpeg offers two encoders:

  • libxvid — external Xvid library, quality‑focused
  • mpeg4 — FFmpeg’s native MPEG‑4 Part 2 encoder

Encoding Options

Using libxvid (Xvid Encoder)

ffmpeg -i input.avi -c:v libxvid output.avi

Using the Native FFmpeg mpeg4 Encoder

ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi

FourCC

Use -vtag to override the default FMP4 FourCC. Example: -vtag xvid

Quality Notes

libxvid generally produces higher quality at low bitrates (~1000 kbit/s for 720p). The native encoder is faster and dependency‑free.

Practical Examples

High‑Quality Xvid Encoding

ffmpeg -i input.mp4 -c:v libxvid -qscale:v 3 -c:a libmp3lame -qscale:a 3 output.avi

Native MPEG‑4 with Xvid FourCC

ffmpeg -i input.mp4 -c:v mpeg4 -vtag xvid -b:v 1500k -c:a mp2 output.avi

References