FFmpeg - Encode MPEG-4 Part 2: Difference between revisions

From PiRho Knowledgebase
Jump to navigationJump to search
Dex (talk | contribs)
No edit summary
Dex (talk | contribs)
No edit summary
 
Line 1: Line 1:
[[Category:FFmpeg]]
[[Category:FFmpeg]]
[[Category:MPEG-4 Part 2]]
[[Category: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.
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 ==
== Context ==
MPEG‑4 Part 2 is used in legacy and AVI-based workflows. FFmpeg supports it through libxvid and the native mpeg4 encoder.
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 ==
== Encoding Options ==
=== Using libxvid ===
=== Using libxvid (Xvid Encoder) ===
<code>ffmpeg -i input.avi -c:v libxvid output.avi</code>
<code>
ffmpeg -i input.avi -c:v libxvid output.avi
</code>


=== Using native mpeg4 ===
=== Using the Native FFmpeg mpeg4 Encoder ===
<code>ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi</code>
<code>
ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi
</code>


== FourCC ==
== FourCC ==
Use -vtag to override the default FMP4 FourCC, for example: -vtag xvid.
Use -vtag to override the default FMP4 FourCC. Example:
<code>
-vtag xvid
</code>


== Quality Notes ==
== Quality Notes ==
libxvid generally produces better output at low bitrates, particularly around ~1000 kbit/s for 720p.
libxvid generally produces higher quality at low bitrates (~1000 kbit/s for 720p). The native encoder is faster and dependency‑free.


== Practical Examples ==
== Practical Examples ==
=== High-quality Xvid ===
=== High‑Quality Xvid Encoding ===
<code>ffmpeg -i input.mp4 -c:v libxvid -qscale:v 3 -c:a libmp3lame -qscale:a 3 output.avi</code>
<code>
ffmpeg -i input.mp4 -c:v libxvid -qscale:v 3 -c:a libmp3lame -qscale:a 3 output.avi
</code>


=== Native MPEG4 with Xvid FourCC ===
=== Native MPEG‑4 with Xvid FourCC ===
<code>ffmpeg -i input.mp4 -c:v mpeg4 -vtag xvid -b:v 1500k -c:a mp2 output.avi</code>
<code>
ffmpeg -i input.mp4 -c:v mpeg4 -vtag xvid -b:v 1500k -c:a mp2 output.avi
</code>


== References ==
== References ==
* https://trac.ffmpeg.org/wiki/Encode/MPEG-4
* https://trac.ffmpeg.org/wiki/Encode/MPEG-4

Latest revision as of 14:35, 14 March 2026

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