Log in

View Full Version : x264 no 100% CPU usage


Racer
23rd September 2012, 13:08
Hello,

Is there any reason why x264 in same cases does not reach 100% CPU load.

My AMD 1045T gives following benchmark results in x264 HD Benchmark 5.0. Especially in the 1st pass my AMD 1045T is only jumping from one core to the other.

Results for x264.exe r2200
x264 Benchmark: 32-bit
==========================

Pass 1
------
encoded 5906 frames, 21.64 fps, 7779.70 kb/s
encoded 5906 frames, 21.65 fps, 7779.70 kb/s
encoded 5906 frames, 21.61 fps, 7779.70 kb/s
encoded 5906 frames, 21.65 fps, 7779.70 kb/s

Pass 2
------
encoded 5906 frames, 9.15 fps, 8003.26 kb/s
encoded 5906 frames, 9.10 fps, 8003.26 kb/s
encoded 5906 frames, 9.08 fps, 8003.26 kb/s
encoded 5906 frames, 9.04 fps, 8003.26 kb/s

An AMD FX6100 seems to gives similar bad results in the 1st pass.
http://forums.techarp.com/reviews-articles/26957-x264-hd-benchmark-5-0-a-6.html#post369848

The interesting thing is that Intel CPU seems to encode way more frames in the 1st pass whereas the 2nd pass is very similar compared to AMD.
http://forums.techarp.com/reviews-articles/26957-x264-hd-benchmark-5-0-a-4.html#post368992
http://forums.techarp.com/reviews-articles/26957-x264-hd-benchmark-5-0-a-4.html#post368941

I have also tested BD Rebuilder. To make sure that decoding is not limiting I have used DGIndexNV in BD Rebuilder, but on some movies I also do not get 100% CPU load.

LoRd_MuldeR
23rd September 2012, 14:39
Without your command-line and especially without knowing what your source is, we can only guess.

In the first pass, x264 uses much "faster" settings, which means that the encoding threads finish much faster and thus the "serial" (non-parallelizable) parts of the program can become the bottleneck.

Still your first pass runs more than twice as fast as the second pass, so don't worry too much about that. If, in the second pass, you still see "low" CPU usage, you may be bottlenecked by slow input!

Last but not least: Keep in mind that it's throughput (frames encoded per second) which matters, not CPU usage. A "higher" CPU usage is not necessarily better...

Racer
29th September 2012, 08:08
Thanks for you feedback. I have done further tests.
With these settings Pass 2 was even slightly faster than Pass 1. Input is AVC (H.264). Any ideas how to improve this.

Pass 1:
x264.exe "F:\WORKING\VID_00001.AVS" --preset superfast --bluray-compat --b-pyramid none --weightp 1 --qpmin=0 --bitrate 8323 --level 4.0 --qpfile "F:\WORKING\VID_00001.CHP" --sar 1:1 --aud --nal-hrd vbr --pic-struct --vbv-bufsize 13000 --keyint 24 --min-keyint 1 --ipratio 1.1 --pbratio 1.1 --vbv-maxrate 15000 --threads auto --thread-input --stats "F:\WORKING\VID_00001.AVS.264.stats" --pass 1 --output NUL

Pass 2:
x264.exe "F:\WORKING\VID_00001.AVS" --preset superfast --bluray-compat --b-pyramid none --weightp 1 --qpmin=0 --bitrate 8323 --level 4.0 --qpfile "F:\WORKING\WORKFILES\VID_00023.CHP" --sar 1:1 --aud --nal-hrd vbr --pic-struct --vbv-bufsize 13000 --keyint 24 --min-keyint 1 --ipratio 1.1 --pbratio 1.1 --vbv-maxrate 15000 --threads auto --thread-input --stats "F:\WORKING\VID_00001.AVS.264.stats" --pass 2 --output "F:\WORKING\VID_00001.AVS.264"

VID_00001.AVS
LoadPlugin("D:\Program Files\DGIndexNV\DGDecodeNV.dll")
DGSource("F:\WORKING\WORKFILES\VID_00023.DGI", fieldop=2)
ConvertToYV12().AssumeFPS(24000,1001)

nm
29th September 2012, 08:57
You might get some improvement by forcing more lookahead threads. By default x264 is using only one lookahead thread on your 6-core CPU (number of threads: 6*3/2=9, number of lookahead threads: floor(9/6)=1).

Try with --threads 12

Racer
29th September 2012, 10:47
This was a good idea. I know also get 100% cpu load for pass 1.
These are my restults:

Pass 1: 83.43fps
Pass 2: 84.29fps

But there is still the questions why pass 1 is not a lot faster then pass 2.
Frameserving/decoding could not be the issue, as this is done by my GT520 and its VPU load ist about 70%.

Groucho2004
29th September 2012, 10:53
The interesting thing is that Intel CPU seems to encode way more frames in the 1st pass whereas the 2nd pass is very similar compared to AMD.

Look closer, you're comparing 64 bit and 32 bit results.
The 64 bit version of their "benchmark" uses a DGDecode.dll with broken IDCT modes and a very buggy avisynth.dll.

These guys really don't know what they are doing and you should not use the results for comparison.

Groucho2004
29th September 2012, 11:05
Pass 1: 83.43fps
Pass 2: 84.29fps

Try measuring the speed of your script alone (without encoder). Use AVSMeter (https://forum.doom9.org/showthread.php?t=165528).

nm
29th September 2012, 11:15
But there is still the questions why pass 1 is not a lot faster then pass 2.

Because you're using --preset superfast, so the settings are pretty much the same for both passes. Since you now get 100% load for pass 1, it can't go any faster without sacrificing even more quality (--preset superfast is already quite bad for the quality/bitrate ratio).

Racer
29th September 2012, 12:10
Try measuring the speed of your script alone (without encoder). Use AVSMeter (https://forum.doom9.org/showthread.php?t=165528).

fps (min/max/avg): 91.41 | 143.44 | 121.23

Frameserving is done by my GT520, and a VP5 can make about 120 fps as shown by the AVSmeter

Groucho2004
29th September 2012, 12:18
fps (min/max/avg): 91.41 | 143.44 | 121.23

Frameserving is done by my GT520, and a VP5 can make about 120 fps as shown by the AVSmeter
I see. Anyway, nm pretty much summed up why you're getting the same speed in P1 and P2.

Racer
30th September 2012, 10:26
By default x264 is using only one lookahead thread on your 6-core CPU (number of threads: 6*3/2=9, number of lookahead threads: floor(9/6)=1).

I have done further testing, but it seems that the default number of threads is not the best number for a AMD 6-core processor. See following benchmark results, I get significant performance improvements if I set "--threads 12".

x264 HD BENCHMARK 5.0 RESULTS
AMD Phenom(tm) II X6 1045T Processor:

Results for x264.exe r2200
x264 Benchmark: 32-bit
==========================

Pass 1
------
encoded 5906 frames, 33.08 fps, 7780.00 kb/s --threads 12
encoded 5906 frames, 33.10 fps, 7780.00 kb/s --threads 12
encoded 5906 frames, 21.59 fps, 7779.70 kb/s --threads auto (default)
encoded 5906 frames, 21.74 fps, 7779.70 kb/s --threads auto (default)

Pass 2
------
encoded 5906 frames, 9.41 fps, 8002.22 kb/s --threads 12
encoded 5906 frames, 9.42 fps, 8002.22 kb/s --threads 12
encoded 5906 frames, 9.03 fps, 8003.26 kb/s --threads auto (default)
encoded 5906 frames, 9.04 fps, 8003.26 kb/s --threads auto (default)

Results for x264.exe r2200
x264 Benchmark: 64-bit
==========================

Pass 1
------
encoded 11812 frames, 40.15 fps, 7754.99 kb/s --threads 12
encoded 11812 frames, 40.06 fps, 7754.68 kb/s --threads 12
encoded 11812 frames, 25.70 fps, 7754.05 kb/s --threads auto (default)
encoded 11812 frames, 25.73 fps, 7754.15 kb/s --threads auto (default)

Pass 2
------
encoded 11812 frames, 9.35 fps, 8002.09 kb/s --threads 12
encoded 11812 frames, 9.33 fps, 8002.08 kb/s --threads 12
encoded 11812 frames, 8.89 fps, 8001.96 kb/s --threads auto (default)
encoded 11812 frames, 8.88 fps, 8001.99 kb/s --threads auto (default)