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

From PiRho Knowledgebase
Jump to navigationJump to search
Created page with "FFmpeg has two encoders to output MPEG-4 video. The external encoding library libxvid:<br/> <code>ffmpeg -i input.avi -c:v libxvid output.avi</code><br/> ...and the native encoder mpeg4:<br/> <code>ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi</code><br/> The native encoder has the advantage of not requiring an external library. Both encoders should provide a similar output, but for lower bitrates/quality (e.g. 1000 kBit/s for 720p content), libxvid will deliver b..."
 
Dex (talk | contribs)
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
FFmpeg has two encoders to output MPEG-4 video. The external encoding library libxvid:<br/>
[[Category:FFmpeg]]
<code>ffmpeg -i input.avi -c:v libxvid output.avi</code><br/>
[[Category:MPEG‑4 Part 2]]
...and the native encoder mpeg4:<br/>
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.
<code>ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi</code><br/>
 
The native encoder has the advantage of not requiring an external library. Both encoders should provide a similar output, but for lower bitrates/quality (e.g. 1000 kBit/s for 720p content), libxvid will deliver better quality than mpeg4.<br/>
== Context ==
The default FourCC stored in an MPEG-4-coded file will be FMP4. If you want a different FourCC, use the -vtag option. E.g., -vtag xvid will force the FourCC xvid to be stored as the video FourCC rather than the default.<br/>
MPEG‑4 Part 2 (sometimes simply “MPEG‑4 Visual”) is an older but still widely supported video compression standard. It remains relevant for:
Reference: [[https://trac.ffmpeg.org/wiki/Encode/MPEG-4 FFmpeg: MPEG-4 Encoding Guide]]
* 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) ===
<code>
ffmpeg -i input.avi -c:v libxvid output.avi
</code>
 
=== Using the Native FFmpeg mpeg4 Encoder ===
<code>
ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi
</code>
 
== FourCC ==
Use -vtag to override the default FMP4 FourCC. Example:
<code>
-vtag xvid
</code>
 
== 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 ===
<code>
ffmpeg -i input.mp4 -c:v libxvid -qscale:v 3 -c:a libmp3lame -qscale:a 3 output.avi
</code>
 
=== 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>
 
== References ==
* 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