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.
If I use
./ffmpeg -hwaccel auto -i input.mp4 -c:v libx264 -b:v 6000k -an output.mp4
on OS-X, then I also get videotoolbox.
What you mention is not related to the encoding. It is the decoding of the source video. You can find the following line in the FFmpeg console:
[h264 @ 0x117e04250] Using auto hwaccel type videotoolbox with new default device
h264 is the decoder here
And in the stream mapping you still see the libx264 (software) encoder for h264.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
You can find more details to this on:
https://trac.ffmpeg.org/wiki/HWAccelIntro