An H.264 encoder refuses frames bigger than 4096 x 2304 (either way round).
On a 5120 x 2160 display the sink writer failed at SetInputMediaType with
0xC00D36B4 (MF_E_INVALIDMEDIATYPE), reported as "the encoder cannot take
frames of this format", and no display could be recorded.
segment::h264_size gives the size to encode at: the display's own, made even,
when H.264 can take it, and otherwise the largest even size of the same shape
that it can (5120 x 2160 is recorded at 4096 x 1728). When that is not the
display's size, a Direct3D 11 video processor scales each frame on the GPU
before it is handed to the encoder. Displays that fit are untouched.
Recorded and decoded on a 5120 x 2160 display: all three screens, undistorted.
Screen capture behind a `CaptureBackend`: ScreenCaptureKit and AVFoundation on
macOS (HEVC by default), Windows Graphics Capture and a Media Foundation writer
on Windows (H.264). Each display is written as fragmented mp4 in segments with
every frame's master-clock timestamp, and a manager decides, from what the
backend reports, when a segment ends and another begins. The segment logic is
shared by both backends and tested without a screen.