At peak (8 jobs x 3 clip workers) balrog sat at load ~100 on 20 threads
while the RTX 4000's decoder stayed at 0%: NVENC only took the encode, and
decoding plus the filter graphs ran on the CPU, starving the Coolify builds
and every other service on the box.
- ffmpeg_utils.video_decode_args(): -hwaccel cuda before the video input
whenever the encode is on nvenc (FFMPEG_HWDECODE=0 turns it off). Used in
the cut, the reframe v2 segments, watermark, hook and caption passes.
- ffmpeg_utils.blurred_backdrop(): the GENERAL and INSET blurred fill blurs
at a quarter of the output size and scales up, instead of a full-size
gblur on 1080x1920.
Measured in the prod container on a real 1080p source, 10 s GENERAL
segment: ~16-18 s of CPU before, ~5-7 s after, SSIM 0.994 against the old
output. All four hwaccel passes checked end to end on the prod GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tried first as a fourth option for the classifier, and it does not work: on the
5 corpus clips that have a composited webcam, Gemini answered "screencast" on
all 5, in both runs, and overall accuracy fell from 92% to 85% and 83%.
3 options 44/48 92% screen preserved 17/20 none intact 27/28
4 options c1 41/48 85% 18/20 28/28
4 options c2 40/48 83% 18/20 28/28
Read that carefully: the fourth option did no HARM (zero regressions across the
28 that must not be touched, and it actually preserved the screen on one more).
It simply never got the new class right. Whether a webcam rectangle is present
is a geometric question, and the detector answers it 5 of 5 with no false
positives.
So the split is: Gemini decides what the video is, geometry decides the framing.
If the decision is "screencast" and camera_inset finds a rectangle, that layout
is used; otherwise full width.
Verified end to end: figma -> screencast + inset on 4 scenes; excel (presenter
composited full-screen, no rectangle) -> full width, as before.
One source: the whole screen (a game, a desktop) with the person composited
into a corner. It is how OBS records and how any stream VOD looks, and it is
the case screencast_layout got wrong: there the speaker band is a large crop
taken AROUND the face, which on a full-screen source means more screen. On the
measured Excel clip the output showed the same spreadsheet twice, whole and
enlarged.
What is needed is the inset's own rectangle, and finding it has three traps,
each of which cost an iteration:
- The inset does not touch two edges. YOLO returns an upper-body box that stops
at the chest, so a webcam pinned to the right side measured 18% clear of the
bottom and the "corner" filter threw it away. The test that works is subject
SMALL and OFF-CENTRE.
- A presenter standing in front of a screen passes any geometric filter. What
separates them is that a composited inset DOES NOT MOVE: 3-11px between
samples versus 316px for a person. With a plain min-max range the filter was
too brittle (one lost sample killed three good detections), so it clusters
around the median and requires a majority.
- The height cannot be scaled from the detection: for a webcam of about 325x180
YOLO returned 246x86, and growing that shape still cut the head off. It is
derived from the width assuming 16:9 and pinned to the edge the inset touches.
The filtergraph keeps the screen at full width (the HUD and the edges are the
content) and the camera band takes its height from the inset's real aspect:
forcing a fixed ratio stretched faces 12% horizontally.
Verified on 10 clips: finds the 4 with a composited camera and rejects the 6
without one (presenter in front of a screen, talking heads, presenter
composited full-screen). The miss is a 720p clip whose webcam is too small for
either detector.