Text contrast in video: why measure against the background that actually shows
Article by Pedro Henrique Lahr
Text contrast in a video has to be measured against what shows behind the letters on that frame. The background color written in the code is almost never the real background: behind the title there may be a photo, a clip, a gradient or another layer. A white title over a bright sky passes any math done in code and vanishes on a phone. Kodecz captures the frame, finds the true color behind each letter, and only then does the math.
Why does the math in the code mislead?
Because the code knows the text color but not what will be behind it. In a video, the background changes all the time: the camera moves, the scene changes, an image slides underneath. The page may say «dark blue background» while, on that frame, the title sits over the sky of a photo.
That was one of the 27 real defects behind the Kodecz Bench: a thin white serif font over a bright sky. In the error taxonomy, «Insufficient contrast» has the cause written down: a color chosen for looks, without measuring the contrast ratio. The symptom gets worse on a phone in the sun and after social-network compression.
What is the minimum contrast?
The ruler is the same one used for accessible web pages (WCAG):
| Text | Minimum ratio |
|---|---|
| Large: 24 px or more, or 18.66 px bold | 3:1 |
| Everything else | 4.5:1 |
The ratio compares the brightness of the letter color with the brightness of the background. 1:1 is the same color; 21:1 is black on white.
How does Kodecz find the real background?
The trick is to capture the same frame twice:
- First capture: the frame as it is.
- Second capture: the same frame with the text fill made transparent. The text's background, box, border and shadow stay; only the letters disappear.
- Comparison: the pixels that change between the two captures are exactly the visible letter pixels.
- Background: the average color of the second capture on those pixels. That is what is behind the letters, only where they show.
The measurement runs on every second of the video and in the middle of the first word of each spoken phrase, which is when the caption changes. Frames are scaled down to 640 pixels wide to keep it fast.
What about text covered by something else?
It is left out. Text behind a box, a modal or a dark layer is not meant to be read, and measuring it would raise false alarms. The check asks the page what is painted on top of each line, at 15 points (five across, three down). One covered point is enough to leave the text out.
Also left out: text that barely shows on the frame (under 0.5% of its box changing between captures) and text with a transparent fill, like a gradient clipped to the letters.
What happens when contrast is low?
It depends on where the text is. On November 1, 2026, it was decided that outside the caption, low contrast is a warning: the agent reads it and explains it. In the caption, since November 4, 2026, it is a failure: the caption is the text that most needs to be read.
The answer does not stop at «this is bad». It brings the text color, the measured background, the required minimum, the ratio found and a ready fix. For a caption, for example: switch to the nearest color that reaches 3:1 on that background, or put a box behind the caption in a brand color. Outside the caption, another text color or an opaque chip behind it.
What are the limits of this measure?
There are three, and they are written in the documentation:
- The background is an average. On a background with two strong colors, half light and half dark, the average can hide the bad half.
- The sample is every 1 second. Text that appears and disappears between two samples is not measured.
- The text color is the one in the code. A filter applied on top that changes the final color is not counted.
So the check does not replace looking at the contact sheet. It clears the obvious cases and leaves the rest to a person.
What does this change day to day?
It changes the order of decisions. The brand palette becomes variables, and the caption is born in a box the color of the background, with its contrast checked. When a brand has an accent too light for text, the check warns before the video goes live. At Konecz, which publishes videos on profiles like Vinhedo Digital and Gatronomia, that avoids finding out in the feed that the title vanished into the sky.
Frequently asked questions
Does a text shadow count as background? Yes. The shadow, border and box of the text stay in the second capture, so they are part of the measured background.
Does it work with text over recorded footage? Yes. The background is captured from the frame, whether it is a color, a photo or a clip.
What about text inside an image? It is not seen. The check reads the page's text; letters drawn into an image are pixels, not text.
Why not require 4.5:1 everywhere? Because large, heavy text reads well with less contrast. It is the same rule as accessible web pages.
More on the Kodecz checks in the summary of the paper on AI agents making video. To get videos with these rules already checked, meet Konecz.