Monday, November 02, 2009

Video Encoding h.264 (x264)


I'm getting ready to switch my FRAPS captures from XVid to H.264 (x264). What I'm finding is that in GTA3: San Andreas, where I capture at 1600x900, encoding to XVid results in a lost of fine detail (even at 2.8-3.0 Mbps settings). The H.264 codec seems to do a much better job at preserving the fine detail while staying at a reasonable bitrate.

StaxRip - This is a very good tool for using in conjunction with FRAPS. If you separate your raw FRAPS AVI files into separate directories prior to encoding, it becomes very easy to merge the AVIs together.

x264 settings - A page at the MeGUI wiki regarding what the different x264 settings are. Pay close attention to "profile", "preset", "tune" and "level".

x264 Encoding Options for Hardware Compatibility & DXVA - Talks about compatibility:

The Bottom Line Everybody should be encoding HD content (1080p, 720p) to Profile High @ Level 4.1. For smooth playback, "--level 4.1" should be used to mark the file as compatible when encoding. The best MeGUI profile for x264 is the DXVA-HD-HQ profile.

The options to xvid are as follows:

--level 4.1 --ref 4 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --filter -1:-1 --trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 50000 --vbv-maxrate 50000 --me umh


And the following quote from that page about standard-def content:

Everybody should be encoding SD content (576p, 480p, or less) to Profile High @ Level 3.1 For smooth playback, "--level 3.1" should be used to mark the file as compatible when encoding. The best MeGUI profile for x264 is the DXVA-SD-HQ profile.

The MeGUI DXVA-SD-HQ profile options:

-level 3.1 --ref 8 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --filter -1:-1 --trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 14000 --vbv-maxrate 17500 --me umh


Note: StaxRip doesn't seem to have an equivalent profile for hi-def encoding. However, using the "Slower" preset takes care of the majority of settings. You'll just have to set the following:

Analysis (Partitions): All enabled except for P4x4"
Frame Options (Misc): Set Reference Frames to 4
Rate Control (VBV): Buffer Size and Max Bitrate to "50000"
Command Line (Custom Switches): Add "--level 4.1"

Which should result in a command line similar to the following:

--crf 24 --preset slower --partitions p8x8,b8x8,i4x4,i8x8 --vbv-bufsize 50000 --vbv-maxrate 50000 --sar 3:4 --level 4.1 --output "" ""

Labels: , , ,



posted by Wuphon's at 5:49 AM (0 comments)

Monday, September 29, 2008

AMD Phenom 9850 and XVid Encoding


So I've been using my new AMD Phenom 9850 quad-core CPU to do a bunch of FRAPS conversions to XVid. The source video is typically 1576x984 (not quite 1680x1050) at 30fps. The output is 1280x720p, XVid format, at around 2.8Mbps with 160Kbps MP3 audio. I'm doing 2-pass encoding for the XVid, which gives superior results over a single-pass style.

Unfortunately, Virtual Dub won't use (currently) more then 2 CPUs, so the Phenom ends up a bit underutilized. So the CPU utilization is only around 50-55% during the first pass and 60-65% during the second pass. (A value of 100% would be running all 4 cores at full utilization. So the 2nd pass is using almost 3 cores.) But since the Phenom 9850 is the 2.5GHz CPU, it's at least doing a passable job at getting the encoding done quickly.

Source video - 30m 59s
Pass 1 - finished in 46 minutes (1.5x more then real-time)
Pass 2 -

So for every minute of source material, I need

Labels: , , ,



posted by Wuphon's at 1:34 PM (0 comments)

Tuesday, February 26, 2008

Converting FRAPS captures to XVid


I've been playing around with my FRAPS video captures this week. FRAPS allows you to capture gameplay (even for full-screen games) into an AVI file. The compression is (what looks like lossless) fairly loose for the captured AVI files (figure 4GB per 2-3 minutes of gameplay).

Obviously, I can't keep lots of 4GB files sitting around. Even though they're very pretty at 1600x900 or 1280x720, they take up a LOT of room. For instance, a 21m 11s video of my priest running around World of Warcraft last September is 10 files and 36.5GB of space (roughly 250Mbps). So I need to pack them down into something more manageable.

Last year, my preference was to convert them to DVD-sized MPEG2 (around 7000-8000Kbps) and stick them on DVDs with about 50-75 minutes of gameplay per disc. That actually worked pretty well, but I soon ended up with dozens of game footage DVDs to keep track of. Which works well if I want to hand a sample of gameplay to someone on a portable format, but a 720x480 image fails to capture a lot of the detail from the original 1600x900 or 1024x768 gameplay. Some games work wonderfully in DVD format (Monkey Island series, Grim Fandango, etc), others suffer from the smaller size where you can't read the text.

(Why save this stuff? I'm a digital packrat and it will be useful in 10-20 years to be able to pull up a clip from a game that can no longer be run on modern systems. It's a way of being able to look back at what game technology was like in the past. It's also a way to show friends / family bits from a game that currently has capture my interest.)

This year, my preference is to go with something a little tighter then MPEG2. Preferably an MPEG4 generation format (DivX, XVID, etc. or maybe H264). While MPEG2 requires a reduction in the video size as well as a lot higher bitrate, MPEG4 (and H264) encoders can work with larger resolution videos yet still pack things down into a tigher bitrate. The downside is that there are no one-step tools out there that convert multiple AVI files into two-pass XVid. I was definitely spoiled by the easy use of TMPGEnc's encoder and batch tools. Still, I can do the enodings using VirtualDub, I just have to be more careful about the process (easier to make mistakes).

What I've settled on is 1280x720p XVid (I think it's progressive), which is a standard HDTV resolution. These AVI files are readable on a variety of systems (such as Ubuntu, and OS X with a bit of work). I'm using the standard "HDTV" XVid Profile to create the AVIs, which will hopefully give me more portability. The 1280x720p resolution is also good enough that I can always downconvert to DVD later if I need to.

The trick then, is to figure out what bitrates work best for 1280x720p game footage. There are no hard and fast rules for this, so it requires a bit of experimenting and deciding what bitrate results in acceptable quality the majority of the time. If I go with too low of a bitrate, certain types of gameplay videos will starve for bits and come out blocky or smeared. Too high, and I'm simply wasting space. So here's what I've figured out. I've been working with a variety of sources (2 FPSs, FEAR and Call of Duty 2 and a MMO, World of Warcraft) and doing a good bit of trial and error.

The audio side of the equation is easy... MP3 audio at 128Kbps (but I'll probably use 160Kbps).

The video side of the equation is less simple. Some of the output quality depends on which XVid decoder you have installed on your system. The older decoders will result in blocky or smeared video output, while newer versions of the decoder will give you much higher quality output from the same AVI file. So when you're testing, make sure that you check the video out on a few different systems. Or simply make sure that you have the latest version of XVid installed.

1280x720p @ 650Kbps -- This is what I originally thought I was going to use. It seems like a generous bitrate (and it is for 640x480 content), but it frequently ends up blocky/smeared for 1280x720. Which makes sense, because 1280x720 has 3x more pixels then 640x480, so the bandwidth needs to be a good bit larger. Not necessarily 3x larger, but probably at least 2x larger. Figure on 6MB per minute of video (around 700 minutes on a regular DVD-R). If I was storing standard-def 640x480 video, I'd probably pick a bitrate around 825Kbps with 160Kbps for the MP3 audio (7.2MB/min or 600 minutes per regular DVD-R).

1280x720 @ 1Mbps -- This works modestly well, unless there is a lot going on with background detail. Then it falls over flat and goes blocky/smeary. Even with 2-pass encoding, a video that is very busy for most of the time results in no "slack" that can be used by the encoder to shore up the bitrate in the really busy parts.

1280x720 @ 1.4Mbps -- This *almost* works for very busy clips. As long at least 1/4 of your video is "quiet" moments (very little camera movement, little backround changes), the compressor might have enough spare bits for the busier sections. Assuming 128Kbps MP3 audio, this results in about 11 MB/min (almost 400 minutes on a normal DVD-R).

1280x720 @ 1.75Mbps -- Works for most situations. Which makes sense since it's about 3x the bitrate of the 650Kbps stream that worked for 640x480. Only the most "busy" of videos will saturate this bitrate level into blocks/smears. Assuming 128Kbps MP3 audio, this uses up around 13.5 MB/min (a bit over 300 minutes on a normal DVD-R).

1280x720 @ 1.9Mbps -- This is the top-level quality. You'd have to work really hard and feed it an extremely nasty video in order to blow out this bitrate. When you include the 160Kbps MP3 audio, you're looking at a bitstream that is right around 2Mbps. A nice round number. A bit under 15 Mb/min (around 300 minutes on a normal DVD-R). If you really want to pack 300 minutes on a regular DVD-R, you should probably trim the bitrate down to 1850Kbps.

I'm probably going to settle in on 1850Kbps video with 160Kbps audio for 16:9 footage. Which should be fat enough to store all of my 1280x720 footage without starving for bits even on the nastiest source videos. I'll scale back to 825Kbps for 4:3 640x480 footage (NTSC source material).

...

Update: While 1850Kbps video works well for some sources, I'm finding that Elder Scrolls IV: Oblivion FRAPS captures aren't quite as forgiving. I've had to step all the way up to 2850Kbps in order to keep the video from going blocky (reliably).

Labels: , , ,



posted by Wuphon's at 12:01 PM (0 comments)

Powered by Blogger Who's linked to me?