Video encoding with x264 and x265 takes a lot of CPU usage. This is because you’re using a software encoder. The whole encoding is done in software and this is executed on your CPU. Modern Macs have a hardware encoder on board. But how to use it with FFmpeg?
We start with a simple FFmpeg command for encoding a video file. With a fixed bitrate and the libx264 software encoder:
./ffmpeg -i input.mp4 -c:v libx264 -b:v 6000k -an output.mp4
Now the same command with the videotoolbox framework from Apple. This uses a hardware acceleration if possible:
./ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 6000k -an output.mp4
In a direct comparison the videotoolbox variant is 4 times faster than the x264 software encoder. Similar results with h265 encoding: hevc_videotoolbox is here 3 times faster than the x265 software encoder. And: the CPU is not fully under load with the hardware encoder. Only 20% of my CPU is used instead of 100% for the software encoding.
Not all commands/parameters are supported by hardware encoder. So some of your flags might not work or be ignored. Check the printed output of FFmpeg for more details.