I’ve been doing a lot of study and testing and benchmarking over the last few months, and I’m to the point now where I can pretty reliably do high quality “HD” xvid encodes for the xbox that don’t drop frames. The key is to understand and account for its limitations, and make appropriate trade-offs.
65K-66K macroblocks per second is about the limit for high quality encodes as things stand at the moment. This translates, for example, to 1280×544@24fps [ie 1280*544*24 / (16*16) = 65280 MBS], which is what you need for 2.35:1 aspect ratio film material.
The jump up to full frame 1280×720, even at the same 24fps, is huge.
1280*720*24 / (16*16) = 86400; you need a 33% increase in the ability of the system to acquire (I/O), process (CPU), and display the video, or you need to take a major hit in the quality (higher quantizers). At 30fps you are talking about 108,000 MBS or 65% more capability (or an even larger decrease in quality).
Besides establishing that MBS limit, I’ve also looked into the ‘spikes’ issue (busy scenes, sudden motion, things that cause the encoder to want to generate bursts of very large frames) and how to constrain it.
In that area, something xvid incorporated at the behest of the divx folk are the dxn hardware profiles. When using one of these profiles, the xvid codec *enforces* ‘max instantaneous’ and ‘total over one second’ bitrates limits. And as it so happens, the bitrate limits for the DXN HDTV profile are just about a perfect match for the xbox / xbmc. (Some of the other parameters for this profile are too generous – 1280×720@30fps – no way jose – but I just stay within the MBS limit I defined above instead).
The other thing I do, a bit more subtle but it helps smooth stream rates and processing out, is limit max consecutive b-frames to 1.
With respect to *average* bit rate; after numerous encode / playback tests, here’s a rule of thumb for you (qualified by everything above). After the first pass (and you must do two-pass for the profile constraints to apply), look at what the average bitrate was for that pass, add 10% to it, and specify that as your target bitrate for the second pass. That’s will typically give an average quant value just below 3, with a few frames maybe up as high as 9 (where the constraints forced a higher quant to stay within the peak limits). As a general rule, you won’t notice them because they are in brief busy scenes.
The ‘high side’ number, if you want to push things, is 4854kbps; that is half of the DVD spec’d max video bitrate, and also half of the DXN HDTV profile max bitrate (gee, what a coincidence!). And my experience, with my V1.0 xbox and Thomson DVD drive, is that if I go much beyond that, the combination of increasing cpu load and dvd drive throughput limitations result in cache depletion during ‘busy’ scenes – no frame drops, but output stutters as the system refills the cache from the dvd. And simply increasing cache size isn’t a solution – there is a detectable cpu hit from overly large caches. If you want to experiment with higher bitrates, you basically have to play them from the hard disk, but keep in mind you are pushing your average closer towards the profile’s max.
Oh, and before I close… So what to do when your source material isn’t 2.35:1? Like it’s 1.85:1 or full frame 16:9 (1.78:1)? What *I* do, is, resize to 960×720…
960*720*24 / (16*16) = 64800 which is within the MBS limit I defined above and happens to be a nice set of number for a whole bunch of reasons (think about it). It is twice the resolution of full frame dvd; it is 1/3rd the resolution of full frame 1920×1080; and it is 3/4th resolution of 1280×720. It’s a 4:3 frame ratio; and when you apply a 4:3 pixel aspect ratio (or simply select xbmc’s ‘stretch 16:9′ view mode) you get your 16×9 picture back.
Anyway, in closing…
Keep your encode under 65K-66K Macroblocks per second
Use the XVID/DXN “HDTV” hardware profile
Set max b-frames = 1
Do two-pass encode
Set average bit rate