Monday, November 02, 2009

H.264 (x264) Encoding times with StaxRip


Just some very (VERY) rough approximations of encoding times with StaxRip. Source material is FRAPS AVI files (1600x900, ~30 FPS), output is 720p (1280x720) x264 MKV files. Encoding system is a quad-core AMD Phenom 9850 (2.5GHz) with 3GB DDR2 RAM. Source and destination disks is a 750GB SATA drive.

Generally speaking, the main part of the encode does a good job of maxing out all of the CPU cores at 80-95% and uses about 800-900MB of RAM. The earlier parts where it demuxes the streams and encodes the audio tend to be more disk intensive. Here are some sample times for the "Slow" preset.

Clip: 4m 15s (255s) - CRF: 22 - 10m 40s (640s) - (2.5x)
Clip: 8m 11s (491s) - CRF: 22 - 23m 18s (1398s) - (2.8x)
Clip: 9m 46s (586s) - CRF: 22 - 32m 27s (1947s) - (3.3x)
Clip: 11m 4s (664s) - CRF: 22 - 30m 12s (1812s) - (2.7x)
Clip: 15m 37s (937s) - CRF: 22 - 49m 51s (2991s) - (3.2x)
Clip: 29m 25s (1765s) - CRF: 22 - 87m 49s (5269s) - (3.0x)

That's too few samples to draw any big conclusions about. And it's too soon to say whether the 3.3x result is out of the ordinary or not. I'm also switching over to the "Slower" preset in StaxRip, so my encoding times are going to go up.

Offhand, I'd say you can count on 3.0x encoding times (3 minutes to encode per minute of source), give or take 10%, for the "Slow" setting.

Slower:

Clip: 15m 58s (958s) - CRF: 23 - 59m 45s (3585s) - 3.7x
Clip: 07m 18s (438s) - CRF: 23 - 39m 32s (2372s) - 5.4x
Clip: 05m 11s (311s) - CRF: 23 - 25m 30s (1530s) - 4.9x
Clip: 12m 17s (737s) - CRF: 23 - 60m 28s (3628s) - 4.9x
Clip: 15m 13s (913s) - CRF: 23 - 72m 44s (4364s) - 4.8x
Clip: 07m 48s (468s) - CRF: 23 - 54m 56s (3296s) - 7.0x
Clip: 12m 03s (723s) - CRF: 23 - 70m 58s (4258s) - 5.9x
Clip: 04m 15s (255s) - CRF: 24 - 16m 22s (0982s) - 3.8x
Clip: 06m 27s (387s) - CRF: 24 - 40m 33s (2433s) - 6.3x
Clip: 11m 04s (664s) - CRF: 24 - 49m 25s (2965s) - 4.5x
Clip: 04m 15s (255s) - CRF: 26 - 15m 07s (0907s) - 3.6x
Clip: 06m 27s (387s) - CRF: 26 - 40m 52s (2452s) - 6.3x
Clip: 11m 04s (664s) - CRF: 26 - 43m 02s (2582s) - 3.9x

Slower is definitely slower, 50-100% longer encoding times over "Slow". I suspect some of the variation might depend on the source material's complexity, but there's not enough data to draw any hard conclusions yet. However, out of the CRF:23 samples, the 7.0x encode was the largest bitrate (5470Kbps) compared to the 2500-3500Kbps of the other encodes.

The command line that I'm using with slower looks like:

--preset slower --partitions p8x8,b8x8,i4x4,i8x8 --vbv-bufsize 50000 --vbv-maxrate 50000 --level 4.1 --output "" ""

I tested CRF for 3 samples. The impact of CRF values on bitrates (shown in Kbps) is as follows:

18: 4820 5130 9840
20: 3267 3864 7100
22: 2520 2975 5260
24: 1970 2320 4050
26: 1515 1770 2940

What you see here is that a CRF of 18 results in very high quality encodes, but with larger bitrates. The one sample ended up at 9840 Kbps, which is huge for my purposes. Setting the CRF to 24 results in a file that is about 60% the size of a CRF 20 encode. Which is a sizeable savings. For archive quality encodes of game video, setting the CRF to 18-22 is probably a good choice, depending on your source footage. For cases where you care more about file size, set the CRF to around 24. Although at CRF 24, you'll start to see blockiness in dark shadowy areas.

Most official sources indicate that you should pick a CRF between 15 and 25, depending on your needs. Which puts the default x264 value of 23 at the upper end of the scale. Most folks talking about movies and TV encodes fall into the 18-20 range, with 22 used for cases where you're willing to compromise image perfection in exchange for file size. Stuff in the 15-17 range seems to be the realm of perfectionists who want zero artifacts.

Of course, for the real fun, the CRF value is not the only determining factor in video quality. Plus, the x264 developers periodically change the math which means that your optimal CRF value may shift a point or three in either direction when you update x264.

Me? I'm going to roll with CRF 23 for the moment for my archived FRAPS footage.

Labels: , , ,



posted by Wuphon's at 7:42 AM

Comments: Post a Comment
Powered by Blogger Who's linked to me?