Page 1 of 1

Control Group Scripting w/HandbrakeCLI

Posted: Thu May 07, 2020 3:35 am
by ahardy
Problem / Description
I have created a cgroup to execute a bash script. The script works however annihilates my CPU and has been tested / proven to work. However my CPU tends to get annihilated when this happens, which is frankly expected as it is encoding after all. I created a control group and forced resource limits to the script to address the whole resource problem. With the cgroup, the file is made but seems like nothing happens.

Side note, I have tried to "set affinity" and use cpulimit aswell for alternatives with zero success. The control groups does indeed run the command with the resources it is set and does generate the new file, but never encodes. I am open to really anything at this point, but I need to control handbrakecli from just ripping into my CPU.

General Detail of Server
- XCP-ng / Xen Host
- Ubuntu 18.04
- HandBrake 1.2.1

Script
find /home/username/sharem/* -type f -size +4000M -exec bash -c 'HandBrakeCLI --encopts="coder=auto" -v0 -i "{}" -o "${0%.*}"-720p.mp4 --preset "Fast 1080p30"' {} \; -exec bash -c 'mv "${0%.*}"-720p.mp4 "${0%.*}".mp4' {} \; -exec bash -c 'rm "{}"' {} \;

Control Group

Code: Select all

[Unit]
Description=Encoding Video Files

[Service]
ExecStart=/bin/bash /home/username/maintain/bashhandbrake.py -d --foreground=true
MemoryAccounting=true
MemoryMax=1024M
CPUAccounting=true
CPUQuota=35%

[Timer]
OnCalendar=Mon *-*-* 5:00:00
Persistent=true

[Install]
WantedBy=multi-user.target

Log
There is no activity log, that I can find on the host. Open to providing it, if you can tell me what the name of the file is or command to make it. Yes I have read the article that was posted.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Thu May 07, 2020 4:08 pm
by mduell
The log is the output to stderr. You can write it to a file using the appropriate redirection syntax for your shell.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Wed May 13, 2020 5:12 am
by ahardy
Figured it out, had to modify the script a bit as I was using the wrong options for gpu encoder / adjusted the preset. The systemctl cpu limitations work but handbrake does not seem to do well by forcing low cpu use.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Wed May 13, 2020 5:15 am
by ahardy
There a way to increase the use of the GPU over CPU? Getting like 100MB use and like 1 to 2% use out of the GPU.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Wed May 13, 2020 12:48 pm
by Woodstock
You would have to have a video card that implements a video encoder chip, such as Intel's QSV, or the equivalent tech from nVidia or AMD. The flatpak distribution can use QSV, but AMD and nVidia are experimental.

"Just" a GPU is not going to be used by handbrake.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Wed May 13, 2020 6:49 pm
by ahardy
Okay, I have p2000 and the script was modified to include -e option for nvenc. However still really low use. I understand that a majority of the load would be on the CPU based from replies / documentation but there is not much documentation on how to increase that load to be more on the GPU oppose to the cpu.

Re: Control Group Scripting w/HandbrakeCLI

Posted: Wed May 13, 2020 6:53 pm
by s55
NVEnc is video encoding only. As such, Decode, A/V Sync, Filters, Audio, Muxing etc are all CPU bound and the CPU can bottleneck the nvidia card.

Also note, NVEnc is not a GPU encoder. It's an ASIC. It's dedicated hardware so it may not show up as GPU usage rather Encode Engine Usage instead.

Finally, We'd need to see an encode log to see if it's working correctly or not.