Some Xvid Video Tests


donny662

Member
Joined
Nov 29, 2005
Messages
375
Website
Visit site
I decided to do a little test of the video playing capabilities of the GP2X. This is quite an informal test; I had the idea about an hour ago. But, I hope this will shed some light on why some videos work and others don't.

MPEG-4 is an advanced video compression specification that allows for many file size saving features. Many of these features require lots of computing power that, until recently, only computers have been able to take advantage of them. Even though in this test the XviD flavour of MPEG-4 codec is used, the features discussed apply also to DivX 4,5,6,3viX, and any other MPEG-4 codec, and unless it has something to do with an XviD specific bug in the GP2X video player, the results of this should also apply to the other MPEG-4 codecs as well.

Three encoding features of the MPEG-4 specification have become popular to use, but because of the limited computing power of handheld and set-top players, these features have not always been supported. So, one may come across video files encoded with B-Frames, Global Motion Compensation (GMC), and Quarter Pixel (Qpel) features.

A B-Frame is a type of picture encoding that is available in all of the MPEG specifications (MPEG-1,2,4), and the idea is also used in most other lossy encoding methods. MPEG video divides the frames into groups called GOPs (Group Of Pictures). The first is an intra or I frame, which stores the full picture much like a JPEG. The rest of the frames in the GOP store only the part of the picture that has changed, so they take up much less space. P-Frames are the simplest, which only store the differnce from the last frame. Basically, they look to the previous frame and only display what is different, hence the title P. B-Frames are more complicated in that they not only look to the previous frame but they can also look at frames ahead of them in the GOP. They are also known as Bi-directional frames. Of the three types of frames, I takes the most data, P less, and B the least to encode, but that also means decoding requires more power for a B-Frame than an I-Frame. For awhile, XviD didn't even implement B-Frames. Enabling B-Frames will probably give the best results in increasing the quality your videos over GMC and Qpel.

GMC is a feature of MPEG-4 that I don't really know much about. It is supposed to increase the quality of the videos, but from what I have read, it isn't that big of a boost, especially for the greater resources it requires.

Qpel I also don't know much about. I believe it offers a good improvement for quality, but is also requires a lot of resources to decode; in fact, it requires the most of these three options.

For this test, I used a two minute clip from a XviD encode of Harry Potter and the Prisoner of Azkaban with resolution of 576x240 and at 25 fps.

I used the program VirtualDubMod for the encoding. The program you use to encode the video doesn't matter as much as the codec (XviD,DivX). The codec handles all of the hard work encoding the video, and the program handles wrapping that video in a container such as avi, ogm, or mp4. For the codec settings, VirtualDubMod uses XviD's built in GUI the same as VirtualDub does. Other programs may use their own GUI to specify the parameters passed to XviD, so the same options are there, but there may be differences in how many options a program gives to you and maybe the default options it sets. If the program you use has basic settings like high and low quality, try to find out if you can select the specific settings it is using to make sure it doesn't enable something that isn't supported by the GP2X.

The B-Frames, GMC, and Quarter Pixel options in the XviD GUI are found by clicking the "more..." button by the "Profile and Level" dropdown.

I made a set of files with different options enabled at the same resolution of the test file and encoded all of them with only one pass at a bitrate of 700kbps and without audio. Also, I made a set at 320x136 to fit the width of the GP2X screen at 300kbps.

I set the following options for the files:
No B-Frames, GMC, or Qpel
B-Frames only
B-Frames and GMC
B-Frames and GMC and Qpel
GMC only
Qpel only

Since I was doing this quickly, I didn't record the encoding time, but I can say having all three options enabled nearly doubled the encoding time and the rest only added about 5-30% to the time.

Every video would jump a little, and it was usually at similar times. But, that shouldn't affect the outcome of the test and may be due to the buggy player or SD reading. I also noticed the jumpiness when I played a DivX3 video. I used a 1GB A-Data SD card I purchased from GP32z with my unit. Also, I have the v1.01 firmware with the mplayer patch installed.

The results are the same between the full and small resolution videos. The B-Frame only videos worked just as well as the video with none of the options. Any video with GMC or Qpel didn't work at all. When I selected the video, the GP2X showed the loading screen, but afterwards, only a black screen was displayed. They don't crash the player or anything because I can still exit to the menu or browser.

Make sure when you encode videos for the GP2X that GMC and Qpel are not enabled. It is a good idea to enable B-frames, though, because the quality of the video will be improved.

If they are in demand, I may post the test videos, but right now I should be studying for my Computer Science exam. It's about 1:30 am now and my exam is at 8:00 am.
 
Thank you so much for clarifying this... i hope this will end some of the buzz and worry. soon i hope they can implement thes other types, unless it takes too much processing power.
 
Could you say something about the relative quality of the videos?

For example, by enabling B-frames, can we get away with a smaller bitrate (and hence a smaller file), while still maintaining image quality?
 
@Rayek
GMC and Qpel might explain some of the problems people are having with videos not playing, but I also think there might be other factors too; I just don't know what they are.

@Axeman
Thanks. I think I did alright, but for some of the answers it came down to the tried and true method of eeny, meeny, miny, mo.

@RiXOR
Yes, you can get away with smaller bitrate. How much? I don't know. You could probably shave as much as 5-10% off the bitrate. Because I did one-pass encoding, I don't think the qualities I achieved best reflect the abilities of the XviD codec. The most beneficial thing you can do to get better quality encodes besides using a higher bitrate is using two-pass encoding.
 
donny662 posted on Dec 8 2005 at 03:03 PM said:
@Rayek
GMC and Qpel might explain some of the problems people are having with videos not playing, but I also think there might be other factors too; I just don't know what they are.

@Axeman
Thanks. I think I did alright, but for some of the answers it came down to the tried and true method of eeny, meeny, miny, mo.

@RiXOR
Yes, you can get away with smaller bitrate. How much? I don't know. You could probably shave as much as 5-10% off the bitrate. Because I did one-pass encoding, I don't think the qualities I achieved best reflect the abilities of the XviD codec. The most beneficial thing you can do to get better quality encodes besides using a higher bitrate is using two-pass encoding.

i thought P frames were predictive frames and are based on the previous and next frame
 
Last edited by a moderator:
i stand slighty corrected

I-frames (independently decodable)

P-frames (predicted from a previous I- or P-frame)

B-frames (predicted from one past and one future I- or P-frame)

Note: B-frame, I-frame, and P-frame are all video compression methods used by the MPEG standard. B-frame is an abbreviation for bi-directional frame, or bi-directional predictive frame. B-frames rely on the frames preceding and following them and only contain data that has changed from the preceding frame or is different from data in the next frame.

P-frame is an abbreviation for predictive frame, or predicted frame. P-frames follow I-frames and contain only the data that has changed from the preceding I-frame. P-frames rely on I-frames to fill in most of its data.

I-frame, also known as keyframes, is an abbreviation for intraframe. An I-frame stores all the data required to display the frame. In common usage, I-frames are interspersed with P-frames and B-frames in a compressed video.
 
That's right. The GOP for I-P only goes like IPPPPPPPPPP, and the standard I-P-B video goes like IBBPBBPBBP. In the XviD codec it has an option for the number of B frames between I or P frames and the default is 2 but you could have orders like IBBBPBBBP if you set that to 3.

Adding more B-frames makes the video more compressable, but when there is an error in a P or B frame, that error will propogate to any subsequent frames until you get to the I frame of the next GOP. You can see that when the video gets a stray block in it, the block gets bigger as the error is passed on to later frames, but it goes away when the next I frame is rendered.

When you are deciding the length of the GOP and number of P/B frames there is a tradeoff between compressablitiy and proneness to errors. DVD limits the number of frames in the GOP to 18 for NTSC and I think it's 15 for PAL, but for MPEG-4 there is no limit to the size, so it is completly up to the codec.
 
Back
Top