Skip to content

Stop dropping frames when camera jitter straddles the frame grid - #10

Merged
dhh merged 3 commits into
omacom:masterfrom
Merovex:fix-dropped-frames
Nov 12, 2026
Merged

dhh merged 3 commits into
omacom:masterfrom
Merovex:fix-dropped-frames

Conversation

@Merovex

@Merovex Merovex commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #9.

Writer::videoAt rounds each frame to the nearest output slot and drops a frame whose slot is taken. The slot grid's phase comes from when Record is pressed. When the camera's frames land near the midpoint between slots, normal jitter (the MX Brio runs 36, 36, 28 ms) rounds consecutive frames onto one slot. About a third of the take's frames are then silently dropped.

A frame that collides with the previous slot now takes the next one, if that slot is at most ¾ of a frame early (~18 ms at 30 fps at most). A camera genuinely faster than the output rate still has its extra frames dropped.

Verification

  • New test jitteryCameraKeepsEveryFrame feeds 60 frames at this phase and jitter: 41 frames are kept before the fix, 60 after.
  • ./bin/test: all pass (19 backend + 3 UI), including the A/V sync test.
  • Real camera (MX Brio, 4K MJPEG 30 fps, with the 4K30 recording stops within seconds: Qt's recorder can't encode it fast enough, even on fast hardware #8 encoder fix applied): six consecutive 4 s takes all recorded a full 30 fps (113–124 frames). Without this fix, roughly one take in four came out at about 20 fps (81–86 frames).

🤖 Generated with Claude Code

The output frame grid's phase is set by when Record is pressed, not by
the camera. When the camera's frames land near the midpoint between
output frames, normal jitter rounds consecutive frames onto one slot and
the second is dropped, silently losing about a third of the take's
frames. Such a frame now takes the next slot when that is at most three
quarters of a frame early; a camera faster than the output rate still
has its extra frames dropped.

Fixes omacom#9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The jitter test now records 320x240 frames, NVENC's minimum, paced at the
camera's own intervals so the encoder queue sees real-time input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh

dhh commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

I merged master into this branch and pushed it. Since #32, recordings go through NVENC, so the jitter test now uses 320×240 frames, NVENC's minimum. It also feeds them at the camera's own 28/36 ms intervals instead of every 5 ms, so the encoder sees real-time input. It still catches the bug: without the fix, 41 of 60 frames survive.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps jittery camera frames without advancing the repeated final frame past its intended slot.

  • Camera frames can take the next slot when jitter makes them collide.

Reviews (2) · Last reviewed commit: "Keep the repeated tail frame from moving..." · Reviewed by Greptile

Comment thread src/writer.cpp Resolved
Only camera frames may take the next slot after a collision. finish()
repeats the last frame to fill the take's final slot, and moving that
repeat forward added a frame after the audio ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh merged commit 23080a3 into omacom:master Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Takes silently lose about a third of their frames when camera jitter straddles the frame grid

2 participants