Compare: H.264, Xvid, MPEG4, MPEG2 & WMV

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Locked
meRobs
Expert
Expert
Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Compare: H.264, Xvid, MPEG4, MPEG2 & WMV

Post by meRobs » Sun May 13, 2012 9:28 pm

[Updated 14 May 2012]

In this Guide we shall examine the video quality for a number of Formats (Codecs), which in turn depends on the Encoder used to create them. To make this comparison I used MediaCoder build 5230 to create the files and the video editor Adobe Premiere CS5.5 to compare their frames. Consequently, we are limited to those formats that are supported by Premiere, such as, MPEG2, MPEG4, H.264, Xvid and WMV.

A standard DVD contains audio/video information as VOBs, which are merely DVD-compliant MPEG2 files created by an authoring program that cuts them up into chunks no bigger than 1 GB and re-names their extensions from MPG to VOB. So, the first format considered in this study is DVD-compliant MPEG2, as discussed in the Guide viewtopic.php?f=17&t=8282&start=0.

I included MPEG4 in AVI because it was recommended in a previous study on formats that suit the video editor, Adobe Premiere CS3 (see: viewtopic.php?f=17&t=9488). In that case, the audio was MP2, which failed to import in Premiere CS5.5. Since then I discovered that importing to Premiere was far more successful when the audio in the source file was AAC rather than MP2, PCM or ADPCM. To see if the Container and/or Multiplexer make a difference, I included MPEG4 in MP4 as well.

H.264 (also known as AVC) in MP4 was included, as suggested for Adobe Premiere CS5.5 (see: viewtopic.php?f=17&t=11959). And, finally, out of curiosity, I chucked Xvid and WMV into the mix. The Xvid format is discussed in the Guide: viewtopic.php?f=17&t=11023 and WMV, in viewtopic.php?f=17&t=11103. Unfortunately, I was not able to try the most recent version of WMV (see the guide)!

1. The Test
The test was limited to PAL since the load on the encoder would be virtually the same as for NTSC. This is so because the bitrate requirement for a given video quality depends on the number of pixels in each frame and the number of frames delivered per second. Thus, for PAL with 720x576 pixels per frame and delivered at 25 fps, the encoder must deal with 720x576x25 pixels per sec and, similarly, 720x480x29.97 for NTSC. In other words, there are 10.368 million pixels per sec to encode for PAL and much the same number for NTSC at 10.358 million pixels per sec.

The source file chosen for this test was an 8:52 min action scene in 720x576 pixels, a chapter ripped as a VOB from a quality DVD. It displays as a 21:9 image on a 16:9 screen (display aspect ratio), i.e., occupying only 75% of the height of a widescreen TV, with black bars top & bottom not consuming any of the bitrate. It had an average video bitrate of 6245 kbps (max of 7840 kbps).

MediaCoder 5230 was then used to encode the source VOB at various video bitrates from 200 to 16,000 kbps, into
(1) MPEG2 video and AC3 audio in the MPEG2 container with the Muxer disabled,
(2) WMV-8 video with ADPCM audio in ASF with the Muxer disabled,
(3) MPEG4 video with LC-AAC audio in AVI with the Muxer enabled as FFmpeg,
(4) MPEG4 video with LC-AAC audio in MP4 with the Muxer enabled as MP4Box,
(5) H.264 video with LC-AAC audio in MP4 with the Muxer enabled as Auto Select and
(6) Xvid video with LC-AAC audio in AVI with the Muxer enabled as FFmpeg.

* The video encoder was FFmpeg for each (including for Xvid), except for H.264, and its tab had B-Frames= 0 and GOP= 12,
* the video encoder for H.264 was x264 and its tab had Profile= Main, Level= 3.0, Preset= Very Fast, B-frames= 3 (all else defaults: 2 Ref frames and GOP=25~250, etc) and
* the Xvid tab had Profile = Advanced Simple Level 5 with High Quality mode & B-frames= 0 (see: viewtopic.php?f=17&t=11023),
* the audio encoder was FFmpeg for AC3 and ADPCM
* in all other cases, the audio was LC-AAC via the Nero Encoder.
* The Picture tab in each case had Resize= 720x576, Frame Rate= 25, Aspect Ratio= Set Display AR at 16:9 (to suit source) and
* the Scale tab had De-interlace enabled as Linear Blend.

Then, the resultant files were imported to Premiere CS5.5 for comparison. Various clips were placed in series along a Timeline and a suitable frame was chosen for the comparison. It was marked in each clip with a marker so that the Monitor could be rapidly switched to the same frame in each clip; and the Preview Monitor was set to display at up to 400% – a magnification of 4x on the PC. The test was repeated for a number of different action frames.

2. Bitrate Limitations
As the bitrate set in MediaCoder is decreased, the bitrate in the output file decreases, but tends to be progressively higher than the set value at low bitrates, and eventually levels off at a minimum. Similarly, at high bitrates the output bitrate tends to plateau out. For the above 8:52 min VOB test file: (1) MPEG2 achieved a min rate of 650 kbps when MediaCoder was set at 200 kbps and a max of 4820 kbps, when set for 8000 kbps. Similarly, (2) MPEG4 was limited to 470 and 4330 kbps, (3) Xvid, to 390 and 3420 kbps and (4) WMV-8 to 690 and 4720 kbps. The exception was the H.264 Codec via x264. It had no practical limits: the output file displayed the value set in MediaCoder.

However, these are average rates for the entire clip. When a 1-min segment of the movie, containing the action bike scene, was ripped as a VOB, the minimum bitrates achieved for these Codecs was higher, in most cases, by 40-70%, depending on the Codec, possibly because the scene required a greater bitrate! And, of course, as before, the video output for the H.264 Codec was exactly at the set bitrate.
This makes it difficult to compare the various Codecs at very low or very high rates. Do we compare files at the same set bitrates or at the rates actually achieved in the output? But, then, the actual rates delivered during the fast-bike scene would not be at the (average) rate for the entire 8:52 min file. For this reason I made direct comparisons at video bitrates set in steps of 500 kbps from 1000 to 3000 kbps, for which the achieved rates were sufficiently close in all cases.

3. The Results
The MPEG2 and MP4 containers carried the correct Pixel Aspect Ratio to Premiere, suitable for 16:9. On the other hand, the others imported with incorrect values and had to be reset by Premiere, using “Interpret Footage”. However, this issue are not relevant to this discussion on video quality.

All clips encoded with video at and below 1000 kbps showed blockiness when viewed at 400%. The video was broken up into macro blocks of 8x8 pixels, as seen in Figure 1, below. In the worst case, the MPEG2 video, frames within an action scene displayed blockiness even when viewed at 100%, until a video bitrate of about 2500 kbps. This result is roughly in accord with earlier studies I had done, which suggested that a video bitrate of about 2300 to 2500 kbps was a reasonably safe minimum, although, as a precaution, I had been using 3000 kbps when exporting from Premiere to Adobe Encore for authoring to DVD. At 3000 kbps for the video and 160 kbps for the audio the capacity of a standard single sided DVD5 disc is about 190 min.

When directly comparing the same action-frame for clips done at the same video bitrates, I judged the quality to be worst for MPEG2 and progressively improved to that for H.264/MP4 and Xvid/AVI. This was judged by the level of blockiness and on how well the frames matched that from the original source VOB, also imported into Premiere. At 1000 kbps, for example, the quality in MPEG2 was slightly worse that for WMV-8 and MPEG4 in MP4, yet all three were clearly worse than the others. This may be seen in Figure 1, which does not include the result for WMV-8 since it was indistinguishable from MPEG4 in MP4. Note that the equivalent frame in the source VOB was included in the Figure for comparison.
Image

Clearly, the quality (level of blockiness, etc) improved in going from MPEG4 in the MP4 container to the same Codec in the AVI container! This is likely due to the different multiplexers (?).

The quality continued to improve in going to Xvid and then to H.264. However, depending on which frame had been chosen for comparison, the quality-order varied among the best three, with Xvid being most often considered the best, and MPEG4/AVI most often the worst of the three. Moreover, the same conclusions were drawn for encodes at 2000 and 3000 kbps.

Figure 2 shows a similar story, but at a viewing magnification of 400%, where the pixels are more obvious. Here, the encodings were also done at a video bitrate of 1000 kbps. At 3000 kbps, the relative quality order was much the same as given in this figure; and there was some blockiness still detectable in all cases, except for Xvid, though very slight. It should be remembered, though, that this assessment is rather severe, being done while viewing at 400% where the individual pixels are clearly visible.
Image

The reason I chose to De-interlace via Linear Blend, rather than Cubic Interpolating, as had been my practice, is that when viewed at 400%, showing the individual pixels, Cubic Interpolating looked too severe and viewing at 100%, the video looked ‘better’.

4. Conclusion
When converting DVD video to formats with the same frame resolutions, the H.264 and Xvid Codecs were considered the best. The latter format gives a slightly better quality at the same bitrate but the former is a more practical choice because the encoding speed for H.264 in MediaCoder is ~5x faster.

From my tests, I conclude that at DVD quality, the best encoding choice is Xvid/AVI with video encoded at 2000 kbps, with little to gain at a higher bitrate. Much the same quality would be achieved by encoding to H.264/MP4 at the higher rate of 3000 kbps, with the advantage of a 5x faster encoding speed. At these bitrates, the action frames I used looked ‘better’ than the VOB originals when viewed at 400%. This is probably because of the softening effect at the pixel level of the de-interlacing by MediaCoder, when compared to the VOB, which was interlaced.

It is also interesting to note that the video quality achieved in MediaCoder, for a particular Codec/format, seems to differ in different Containers! This was clear for MPEG4 video in the containers AVI and MP4 and, I guess, this may be related to the size of the GOP (12 for MPEG4 and 25~250 for H264) or to the multiplexing (FFmpeg for AVI versus MP4Box for MP4).
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

meRobs
Expert
Expert
Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Re: Compare: H.264, MPEG4, MPEG2, etc

Post by meRobs » Sun May 13, 2012 9:30 pm

The above test was prepared as a Guide.
So, please, if you have any comments or criticisms please put up a new Topic, quoting this guide.
Thanks
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

Locked