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

From PiRho Knowledgebase
Jump to navigationJump to search
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 has two encoders to output MPEG-4 video. The external encoding library libxvid:<br/>
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.
<code>ffmpeg -i input.avi -c:v libxvid output.avi</code><br/>
 
...and the native encoder mpeg4:<br/>
== Context ==
<code>ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi</code><br/>
MPEG‑4 Part 2 is used in legacy and AVI-based workflows. FFmpeg supports it through libxvid and the native mpeg4 encoder.
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/>
 
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/>
== Encoding Options ==
Reference: [[https://trac.ffmpeg.org/wiki/Encode/MPEG-4 FFmpeg: MPEG-4 Encoding Guide]]
=== Using libxvid ===
<code>ffmpeg -i input.avi -c:v libxvid output.avi</code>
 
=== Using native mpeg4 ===
<code>ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi</code>
 
== 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 ===
<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 ===
<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

Revision as of 13:55, 14 March 2026

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

References