9

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?

2 Answers 2

10

On MacOSX there’s Videotoolbox, a low-level framework that provides direct access to hardware encoders and decoders. It provides services for video compression and decompression, and for conversion between raster image formats stored in CoreVideo pixel buffers. These services are provided in the form of session objects (compression, decompression, and pixel transfer), which are vended as Core Foundation (CF) types.

FFmpeg implements Videotoolbox in both hardware contexts (for H/W acceleration bring-up) and as encoder wrappers (for transcoding supported codecs).

Check out the private encoder options for hevc_videotoolbox encoder wrapper:

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)

Note that the output may change over time as more features are exposed in more recent ffmpeg builds.

Maybe you can test with that, if you have a recent Mac.

As you can see, it taps into the hardware-based encoders available on macOS, offering a unified API for video encoding across multiple vendor-specific abstractions, ranging from Intel (Quicksync) and AMD GPUs (Prior generation VCE and current generation VCN SIP blocks) on x86, and including the latest Apple Silicon's M-series ARM SoCs.

Grab a build here: https://evermeet.cx/ffmpeg/

1
  • Are args like -crf or -b:v available in hevc_videotoolbox? Or how to check an arg is common or specific to an encoder? Thanks!
    – amdyes
    Commented Aug 19, 2019 at 3:45
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .