macOS (Apple Silicon): 4K stream capped at ~55 FPS because AV_CODEC_FLAG_LOW_DELAY forces VideoToolbox low-latency rate control
Is there an existing issue for this?
- I have searched the existing issues
Is your issue described in the documentation?
- I have read the documentation
Is your issue present in the latest beta/pre-release?
Tested on stable v2026.914.233613. I did not run the latest pre-release, but the same code is still on master (src/video.cpp, make_avcodec_encode_session).
Describe the Bug
On Apple Silicon, a 3840×2160 stream is capped at about 55 FPS even though the client requests 120 FPS and the VideoToolbox HEVC encoder can do about 97 FPS at 4K on the same machine.
The cause is that make_avcodec_encode_session always sets:
ctx->flags |= AV_CODEC_FLAG_CLOSED_GOP | AV_CODEC_FLAG_LOW_DELAY;In FFmpeg's videotoolboxenc.c, AV_CODEC_FLAG_LOW_DELAY on H.264 (and on HEVC on arm64) turns on kVTVideoEncoderSpecification_EnableLowLatencyRateControl. With that on, each 4K HEVC frame takes about 18–20 ms to encode on an M4, which limits the stream to about 50–55 FPS. Without it (still RealTime = true, no frame reordering, one frame in and one frame out), each frame takes about 10 ms, or about 97 FPS.
AV_CODEC_FLAG_LOW_DELAY is only removed in the VideoToolbox fallback options ({"flags", "-low_delay"}), so users cannot turn it off from the config.
What Sunshine sends: with min_log_level = 0, I counted Sent Frame lines per second while Moonlight requested 3840×2160 at 120 FPS and 150 Mbps. The result was 55.1 FPS on a static desktop (10 s) and 55.2 FPS with a window animating the whole time (16 s). The two numbers being the same points to a fixed cost per encoded frame, not to capture.
Standalone VideoToolbox benchmark (encoder otherwise idle, one frame at a time with VTCompressionSessionCompleteFrames after each frame, 150 Mbps, desktop-like content, M4):
| Resolution / codec | Low-latency rate control on (Sunshine today) | off |
|---|---|---|
| 3840×2160 HEVC | 50–55 FPS (18.3–20.1 ms/frame) | 97 FPS (10.3 ms/frame) |
| 3840×2160 H.264 | 54 FPS (18.4 ms/frame) | — |
| 3200×1800 HEVC | 68 FPS (14.7 ms/frame) | 136 FPS (7.4 ms/frame) |
| 2880×1620 HEVC | 81 FPS (12.4 ms/frame) | — |
| 2560×1440 HEVC | 98 FPS (10.2 ms/frame) | 201 FPS (5.0 ms/frame) |
| 1920×1080 HEVC | 182 FPS (5.5 ms/frame) | — |
Capture is not the limit: AVCaptureScreenInput on a 3840×2160 @ 120 Hz virtual display delivers about 90–100 FPS.
Expected Behavior
There should be a way to reach the encoder's real throughput at high resolutions on Apple Silicon. For example:
- a VideoToolbox option (for example
vt_low_latency_rc = enabled/disabled) that decides whetherAV_CODEC_FLAG_LOW_DELAYis set for*_videotoolbox, or - not setting
AV_CODEC_FLAG_LOW_DELAYfor VideoToolbox when the requested resolution × FPS is higher than what the low-latency mode can sustain.
Additional Context
- Side note on diagnostics: on macOS, every verbose
Sent Frame ...line ends withDupe. Instream.cpp,frame_is_dupeis set whenpacket->frame_timestampis empty, and the AVFoundation capture path never setsimg->frame_timestamp. As a result, every frame looks like a duplicate on macOS, which makes the duplicate/new frame count unusable there. - I can share the benchmark source if useful (about 60 lines of C against VideoToolbox).
- Client: Moonlight 6.1.0 on Windows 11 (RTX 5070 Ti, hardware HEVC decode), 3840×2160 @ 120 FPS, 150 Mbps, V-Sync off. The host display is a
CGVirtualDisplay, 3840×2160 HiDPI, at 170 Hz.
Host Operating System
macOS
Operating System Version
macOS 27.0 (26A428)
Architecture
arm64/aarch64
Package
macOS - dmg
GPU Type
Apple Silicon
GPU Model
Apple M4 (10-core GPU)
GPU Driver/Mesa Version
n/a (macOS 27.0 26A428)
Capture Method
AVCaptureScreen (macOS)
Source: LizardByte/Sunshine