Background info: Apple provides hardware acceleration support for encoding h264 and h265 videos through VideoToolbox. ffmpeg has built-in support for VideoToolbox through the h264_videotoolbox codec.

Problem: I have a bunch of .png images I want to make into a high-quality mp4 video. Using "-crf 18" works fine without hardware acceleration, as in the following:

ffmpeg -pattern_type glob -i '*.png' -framerate 25 -c:v libx264 -crf 18 -preset veryslow out.mp4

But this takes forever. I can force a bitrate and use my Mac's hardware acceleration by doing something like this:

ffmpeg -hwaccel videotoolbox -pattern_type glob -i '*.png' -framerate 25 -c:v h264_videotoolbox -b:v 7000k out.mp4

...which encodes at 100fps rather than <10fps without hardware acceleration. But I'd really like to have constant high quality, not constant bitrate.

There seems to be next to no documentation for the h264_videotoolbox codec, and no explanation of what these options actually mean:

user@machine$ ffmpeg -h encoder=h264_videotoolbox
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_5 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags=-fno-stack-check --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Encoder h264_videotoolbox [VideoToolbox H.264 Encoder]:
    General capabilities: delay 
    Threading capabilities: none
    Supported pixel formats: videotoolbox_vld nv12 yuv420p
h264_videotoolbox AVOptions:
  -profile           <int>        E..V..... Profile (from 0 to 4) (default 0)
     baseline                     E..V..... Baseline Profile
     main                         E..V..... Main Profile
     high                         E..V..... High Profile
  -level             <int>        E..V..... Level (from 0 to 52) (default 0)
     1.3                          E..V..... Level 1.3, only available with Baseline Profile
     3.0                          E..V..... Level 3.0
     3.1                          E..V..... Level 3.1
     3.2                          E..V..... Level 3.2
     4.0                          E..V..... Level 4.0
     4.1                          E..V..... Level 4.1
     4.2                          E..V..... Level 4.2
     5.0                          E..V..... Level 5.0
     5.1                          E..V..... Level 5.1
     5.2                          E..V..... Level 5.2
  -coder             <int>        E..V..... Entropy coding (from 0 to 2) (default 0)
     cavlc                        E..V..... CAVLC entropy coding
     vlc                          E..V..... CAVLC entropy coding
     cabac                        E..V..... CABAC entropy coding
     ac                           E..V..... CABAC entropy coding
  -a53cc             <boolean>    E..V..... Use A53 Closed Captions (if available) (default true)
  -allow_sw          <boolean>    E..V..... Allow software encoding (default false)
  -require_sw        <boolean>    E..V..... Require 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)

What is "level"? How do "baseline"/"main"/"high" differ and what is a "profile"...?

I'd appreciate examples of how to use h264_videotoolbox properly with ffmpeg and specifically how to achieve something like the CRF option that exists with the default h264 codec.

1 Answer 1


I don't know if the documentation has been updated since your post but here it is from the doc:

Constant quality with -q:v. Note that the scale is 1-100, with 1 being the lowest and 100 the highest

Aside from that, no idea as to if the scale is logarithmic or not and what is the default value if any.

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