Skip to content

Skip MJPEG frames the camera cut short - #40

Merged
dhh merged 2 commits into
masterfrom
drop-truncated-jpeg
Nov 12, 2026
Merged

dhh merged 2 commits into
masterfrom
drop-truncated-jpeg

Conversation

@dhh

@dhh dhh commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #24.

The C920 delivers about 4% of its 1080p MJPEG frames incomplete. uvcvideo flags them with V4L2_BUF_FLAG_ERROR, but Qt's V4L2 camera ignores the flag and passes them on as ordinary frames. They decode as a full-screen colour grid in the preview and in the recording. #19 made MJPEG 1080p the C920's default, so this now shows up for anyone with that camera.

Monologue can't see the flag, but it can see the damage: a cut-short JPEG never reaches its end-of-image marker. Backend::receiveVideo now skips a Format_Jpeg frame unless it starts with SOI (FF D8) and ends with EOI (FF D9), allowing up to 64 bytes of padding after it. A skipped frame doesn't reach the preview or the writer, so the recording holds the previous frame for that slot. Frames in any other format pass untouched. The check reads only the first two and last 64 bytes.

On a Logi 4K Pro, whose MJPEG frames end exactly in FF D9, takes keep the same number of frames as master.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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; both previous findings are fixed.

Summary

Skips incomplete MJPEG frames before they reach the preview or recording. Other frame formats pass unchanged.

  • Cut-short MJPEG frames no longer reach the preview or recording.

Reviews (2) · Last reviewed commit: "Let only whole frames count as the camer..." · Reviewed by Greptile

Comment thread src/backend.cpp Resolved
Comment thread src/mediautils.cpp Resolved
…full 64 bytes of padding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh merged commit e37ec88 into master Nov 12, 2026
2 checks passed
@dhh
dhh deleted the drop-truncated-jpeg branch November 12, 2026 16:36
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.

C920 MJPEG: incomplete frames flagged by the driver are recorded as garbage (Qt ignores V4L2_BUF_FLAG_ERROR)

1 participant