Search code examples
ffmpegterminalcpu-usageapple-m1apple-silicon

How to limit cpu usage for a terminal command that works on m1 mac and macOS Monterey?


I have a m1 macbook pro and I regularly need to do some heave processing with ffmpeg. When I do it, all my 8 cores go at it 100% and my cpu temperature goes to 92°C, which I don't feel comfortable about.

I don't really need 100% speed, I'd much rather see 80°C and wait 5x longer for it to finish.

I use Macs Fan Control which sets my fan at 100% at 75°C, so this helps definitely, but is not enough.

I tried ffmpeg -threads 1 parameter but it doesn't make a difference in compressing speed nor temperature, so I assume it just doesn't work.

I tried cpulimit -l 60 -i ffmpeg ... and it doesn't change a thing, so I assume it also doesn't work. cpulimit -l value gives 100% for every core, so cpulimit -l 800 should be 100%, -l 400 should be 50% and -l 60 should be 7.5%.

I tried nice and it is not for my use case. Even with the lowest priority the task uses all available cpu, resulting in 92°C.

Did anybody figure it out for m1 macs already?


Solution

  • So I tried running cpulimit -l 10 -i ffmpeg -i input.mkv -vcodec libx264 -crf 24 output.mp4 and it actually slowed down the cpu.

    The cpu usage (all cores) was between 60-70% and temperature also was about 60-65°C. enter image description here

    The compressing speed went down from about 3.5-4.0x to 2.0-2.5x, so very minimally.

    -l 10 should mean 1.25% cpu theoretically. I don't know why, but this is usable.