Limit Handbrake Useable CPU Cores in Windows

The CPU limit argument of Handbrakes seems to have no effect in Windows. One way to get around this is to start Handbrake with the built-in “start” command with the affinity argument.

start /wait /affinity 33 "" "C:\Program Files (x86)\MC-TVConverter\tools\handbrake\HandBrakeCLI.exe" -i "K:\example.mkv" -e x264 -q 20.0 -d -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 -f mp4 -C 2 -X 720 -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -o "K:\example.mp4"

Here, I use a batch to encode files numbered sequentially.

@echo on
set count=10
:run
set /a filenumber=%count%
if %count% lss 10 set filenumber=0%count%
start /wait /affinity 33 "" "C:\Program Files (x86)\MC-TVConverter\tools\handbrake\HandBrakeCLI.exe" -i "K:\exapmple%filenumber%.mkv" -e
x264 -q 20.0 -d -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 -f mp4 -C 2 -X 720 -m -x
cabac=0:ref=2:me=umh:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -o "K:\example%filenumber%.mp4"
set /a count+=1
if %count% leq 13 goto :run

Affinity takes an hex input. For example, forcing only the use of cores 0,1,4,5 requires an affinity of 33 (110011).

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *