Is it possible to get FFmpeg to use hardware acceleration for HEVC transcoding on macOS?
12,529
Solution 1
On macOPS there’s videotoolbox.
Check this out for the encoder options:
ffmpeg -hide_banner -h encoder=hevc_videotoolbox
Output:
Supported pixel formats: videotoolbox_vld nv12 yuv420p
hevc_videotoolbox AVOptions:
-profile <int> E..V.... Profile (from 0 to 3) (default 0)
main E..V.... Main Profile
main10 E..V.... Main10 Profile
-allow_sw <boolean> E..V.... Allow software encoding (default false)
-realtime <boolean> E..V.... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false)
-frames_before <boolean> E..V.... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false)
-frames_after <boolean> E..V.... Other frames will come after the frames in this session. This helps smooth concatenation issues. (default false)
Maybe you can test with that, if you have a recent Mac.
More on videotoolbox: https://developer.apple.com/documentation/videotoolbox
As you can see, it taps into the hardware-based encoders available on macOS, offering a unified API for video encoding across multiple abstractions (Intel's QuickSync on supported Intel IGPs, etc).
Grab a build here: https://evermeet.cx/ffmpeg/
Solution 2
Not sure if this has changed since the OP's comment, but in FFmpeg 4.x the command is:
ffmpeg -hide_banner -h encoder=hevc_videotoolbox
Related videos on Youtube
Author by
Misha
Updated on September 18, 2022Comments
-
Misha almost 2 years
I have a MacBook Pro with a Kaby Lake processor running macOS High Sierra (10.12). Is it possibe somehow to setup FFmpeg to utilize hardware encoding of HEVC with toolbox, instead of libx265?
-
amdyes almost 5 yearsAre args like
-crf
or-b:v
available in hevc_videotoolbox? Or how to check an arg is common or specific to an encoder? Thanks! -
Giacomo1968 over 4 years@amdyes Nope. I am running macOS Mojave (10.15) on a 2019 MacBook Air with the latest install of FFmpeg from Homebrew, and honestly using
hevc_videotoolbox
is quite horrible. Speed is 2x to 3x playback speed of the source video, which is great! But the quality of the output is abysmal to be honest. The only way I got it to show decent (but still not great) quality for 720p video was by using-profile:v main -b:v 5500k
but the filesize is not much different than the source 1080p video. Might be useful for streaming crappy video but seems like a experimental feature for now.