Sample Header Ad - 728x90

How do I get ffmpeg to encode using constant quality with h264_videotoolbox hardware acceleration for Macs?

4 votes
1 answer
3221 views
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 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 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 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 E..V..... Use A53 Closed Captions (if available) (default true) -allow_sw E..V..... Allow software encoding (default false) -require_sw E..V..... Require software encoding (default false) -realtime E..V..... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false) -frames_before E..V..... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false) -frames_after 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.
Asked by M. C. (109 rep)
Jul 13, 2020, 10:58 PM
Last activity: Feb 23, 2023, 10:02 AM