Balooga.com

A comparison of the encoding efficiencies of the MPEG2, MPEG4-2 and h.264 / MPEG4-10 (MPEG4 part 10) video compression algorithms

Description

I conducted a technology review comparing the coding efficiency of the MPEG2, MPEG4-2 and MPEG4-10 (MPEG4 part 10, h.264 or h.26l) codecs in order to pick an effective and efficient compression algorithm to be used in a new satellite DBS system. The goal of these tests was to achieve the highest quality video at the lowest possible bit rate, thus allowing a large number of video channels to be placed into a single satellite transponder.

We were hoping to fit upwards of 25 full screen video channels into a transponder by encoding each channel at an average of 1.2Mbps. All channels would be stat muxed within a transponder. Stat muxing channels allows an encoder to maintain video quality by varying the bit rate for that channel above or below the 1.2Mpbs average, as dictated by the source material. In a nutshell,

"the objective of statistical multiplexing is to dynamically distribute the available channel bandwidth among the video programs in order to maximize the overall picture quality of the system" [IBM]

The difference in video quality at 1.2Mbps between the older MPEG4-2 algorithm and the new MPEG4-10 (h.264) algorithm is quite marked, as can be seen in the following screen shots.

Split screen view: h.264 and MPEG4-2 at 1.2Mbps

I downloaded several uncompressed clips in Berkley YUV format and, using netPBM, converted these to Windows AVI. Each clip was encoded at an average of 2Mbps and 1.2Mbps using the Microsoft ISO MPEG4-2 encoder and the MPEG committee MPEG4-10 (h.264) reference encoder.

The processor power required by the new MPEG4-10 algorithm is an order of magnitude greater than the older MPEG4-2 algorithm. Using a 2Ghz Pentium 4 with 768MB RAM, encoding an 8 second sequence using the Microsoft MPEG4-2 encoder took under 60 seconds. Encoding the same sequence using the reference MPEG4-10 encoder took two hours. Note that the reference MPEG4-10 encoder is a proof of concept and is not yet optimized.

I have created a DVD that can be viewed in a consumer DVD player showing the results of these tests. The DVD contains split screen views, full screen views etc. These frames are taken from the video on the DVD.

At the moment there are no real-time decoders available, so it is not possible to encode video using MPEG4 part 10 and then play it back in Windows Media Player (or any player, for that matter).

Process

Here is the workflow that I used in order to convert a h.264 compressed video to AVI format so that it can be viewed in a media player in MS Windows (e.g. Windows Media Player).

Required:

Converting the VCEQ ( http://www.vqeg.org ) ( ftp://ftp.crc.ca/pub/crc/vqeg/ ) video sequences to 4:2:0 Berkley YUV, suitable for encoding:
  1. Use yuv2avi to convert the 4:2:2 source material to an avi file. This conversion process also decimates the video from 4:2:2 to 4:2:0:
    • Example command line: yuv2avi.exe src19_ref__525.yuv src19_ref__525.avi 525 UYVY
    • NOTE: It is essential to convert whatever video you want to encode into a base format, like ppm. So if you are unable to use yuv2avi , then use an application like VirtualDub to save your video to a sequence of images in .BMP format (e.g. image_0001.bmp, image_0002.bmp, image_0002.bmp)
  2. Use VirtualDub to:
    1. Crop the x/y video resolutions to multiples of 16, e.g 720x480, 352x288 etc.
    2. Split the video into separate .bmp images.
  3. Use bmptoppm in the Netpbm package to convert each .bmp image to a .ppm image.
  4. * Use ppmtoeyuv in the Netpbm package to convert each .ppm image to a corresponding Berkley yuv image.
    • "for i in image*.bmp; do bmptopnm.exe $i | ppmtoeyuv.exe >`basename $i .bmp`.yuv; done"
  5. Use the MSDOS copy command to create a single eyuv video file from the individual images:
    • "copy.exe /b *.yuv video.yuv"
  • Encode your source video (4:2:0) using the h.264 encoder. The h.264 codec (at least the version I used) does not support 4:2:2 video. This may have changed.
  • Decode the compressed file using the h.264 decoder. This results in a Berkley EYUV encoded file.
Converting the h.264 encoded file into an .avi file that can be viewed in Windows:
  1. Use eyuvtoppm in the Netpbm package to convert the Berkley yuv encoded video to a single ppm file containing the video frames.
  2. * Use pnmsplit in the Netpbm package to write out the individual frames from the ppm sequence:
    • eyuvtoppm.exe -w $WIDTH -h $HEIGHT < decoded_file.yuv | pnmsplit.exe
  3. * Convert each .ppm image to a .bmp image:
    • for i in image*; do ppmtobmp.exe $i >`basename $i `.bmp; done
  4. Use VirtualDub to create an avi file from the sequence of .bmp images

If you want to view a file you have encoded using h.264, you must first decode it to uncompressed EYUV format and then either view the uncompressed video in a application capable of playing this format, or convert the file to AVI. In my case, I took an 8 second clip of 177 Megabytes in size and compressed it down to around 2 Megabytes. To watch it I had to decompress it (back to 177 Megabytes) and then convert it to AVI format.

And there you have it. Easy huh ? ;)