[Home]FFmpeg Vs. Mpeg2enc

Showing revision 11
When encoding video to MPEG2 format, such as when creating a DVD video disc, there are two choices of export module: ffmpeg and mpeg2enc. Which one is better?

The answer, of course, depends on your particular needs. The canonical answer is that ffmpeg is faster while mpeg2enc is higher quality. However, for many applications, ffmpeg is the better choice, because mpeg2enc does not degrade well; if your source is low-quality (such as analog TV broadcasts) or you're encoding at a low to medium bitrate (less than 4000 kbps), ffmpeg will often perform better. On the other hand, if you're saving something for posterity and you don't mind spending the time, mpeg2enc may give you a better result.

Whichever you choose, make sure you have the latest (preferably CVS) version of that software installed. In particular, mpeg2enc from 2005/1/1 CVS runs considerably faster than the previous release (1.6.2).

It's also worth noting that ffmpeg has a two-pass feature (activated by transcode's -R option): the first time through, the encoder saves information about each frame, and the second time, it uses this information to allocate bits more effectively. This results in better quality at a given bitrate (particularly in high-motion scenes) or a reduction in bitrate at the same quality. The extent of either effect is highly dependent on both the bitrate used for encoding and the quality and type of the source material; still scenes show little change, but distortion can be reduced significantly in high-motion scenes encoded at a low bitrate. However, the rate control code (as of FFmpeg 0.4.9b1 and 2005/1/1 CVS) has a design flaw that can cause it to exceed the maximum bitrate allowed during the second pass, which will show up as "SCR underflow" or similar errors when multiplexing the video. According to the FFmpeg developers, a redesigned rate control system is under development.


Visual comparison

The following tables show a comparison of FFmpeg and mpeg2enc encoding of a high-motion scene (the source is interlaced TV). For comparison, the same scene encoded with the commercial Windows encoder [TMpgEnc Plus] (2.524) at 3000 kbps is also shown.

Full images:
Codec 3000 kbps9000 kbps
Original image [704x480 PNG]
FFmpeg (1-pass)[704x480 PNG][704x480 PNG]
FFmpeg (2-pass)[704x480 PNG][704x480 PNG]
mpeg2enc [704x480 PNG][704x480 PNG]
TMpgEnc [704x480 PNG]

Note the distortion in the faces below. FFmpeg's 2-pass processing gives it a clear advantage at 3000 kbps, but even at 9000 kbps the lower half of the left face comes out slightly better with 2-pass FFmpeg. mpeg2enc's poor performance at low bitrates is also clear. (TMpgEnc, incidentally, does better at 3000 kbps than either FFmpeg or mpeg2enc at 9000 kbps in these examples, but has significantly more horizontal noise--compare the full-screen image with the original above.)
Codec 3000 kbps 9000 kbps
Original image
FFmpeg (1-pass)
FFmpeg (2-pass)
mpeg2enc
TMpgEnc

Significant "blocking" can be seen here at 3000 kbps--note the "slips" every 16 scanlines. Again, 2-pass FFmpeg proves superior at 3000 kbps, but all three codecs perform just fine at 9000 kbps.
Codec 3000 kbps 9000 kbps
Original image
FFmpeg (1-pass)
FFmpeg (2-pass)
mpeg2enc
TMpgEnc

The command lines used for encoding are as follows: (the -j is to clip black borders from the source, and to correct the aspect ratio--DV video has a slightly wider field than SDTV)

FFmpeg (pass 1):
transcode -i source.dv \
          -x dv,null \
          -o ffmpeg1.m2v \
          -y ffmpeg,null \
          --export_prof dvd-ntsc \
          -w
bitrate \
          --export_asr 2 \
          --encode_fields b \
          -j 0,10,0,6 \
          -R 1,ffmpeg.log

FFmpeg (pass 2):
transcode -i source.dv \
          -x dv,null \
          -o ffmpeg2.m2v \
          -y ffmpeg,null \
          --export_prof dvd-ntsc \
          -w
bitrate \
          --export_asr 2 \
          --encode_fields b \
          -j 0,10,0,6 \
          -R 2,ffmpeg.log

mpeg2enc:
transcode -i source.dv \
          -x dv,null \
          -o mpeg2enc.m2v \
          -y mpeg2enc,null \
          --export_prof dvd-ntsc \
          -w
bitrate \
          --export_asr 2 \
          --encode_fields b \
          -j 0,10,0,6

TMpgEnc Plus was configured for 2-pass VBR MPEG2 with maximum bitrate 9000 kbps and other parameters left at default.


My personal experience is that ffmpeg runs around 3-4 times as fast as mpeg2enc per frame, but ffmpeg seems to always leave a little bit of visual noise hanging around, while mpeg2enc looks very clean if given enough bitrate. On the other hand, I've occasionally seen mpeg2enc generate "splotches" of color in otherwise motionless areas that grow throughout a GOP and are very noticeable even on SDTV. I don't know whether that's because of noise in the source, a bug in mpeg2enc at high bitrates (I've only seen it 4500 kbps and above--maybe the bitrate was too high and mpeg2enc didn't know what to do with the extra bits?), or what.

--achurch

Transcode Wiki | Recent Changes | Preferences
Password required to edit | View other revisions | View current revision
Edited May 24, 2006 7:37 am by Achurch (diff)
Search: