feat(videos): take gallery thumbnails from a representative frame (~1s in), not frame 0 - #199
Draft
lstein wants to merge 2 commits into
Draft
feat(videos): take gallery thumbnails from a representative frame (~1s in), not frame 0#199lstein wants to merge 2 commits into
lstein wants to merge 2 commits into
Conversation
…s in), not frame 0 Frame 0 is a poor thumbnail source: generated videos commonly fade in from black, and an audio-only upload wrapped in the synthesized waveform track renders its first frame from a near-empty audio window - an undistinguished black tile in the gallery. Add representative_thumbnail_frame_index (~1s into the clip, capped at its midpoint; untrusted/absent metadata degrades to frame 0) and extract_representative_video_frame (falls back to frame 0 when the computed index has no decodable frame, so overstated container metadata still yields a thumbnail; a decode timeout propagates without a second attempt so an adversarial upload cannot double its hold on a request worker). Wire it through both thumbnail producers: the upload probe (which already decodes a frame to prove decodability - it now proves it on the representative frame, same acceptance semantics) and the disk store's save-time fallback used by generated/derived videos, with duration/fps now passed down from the video service. The copy path still reuses the source's existing thumbnail. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xFbHnmFTLsHE9e1PAdvme
- A timeout is now never retried in either mode: the helper raises internally to distinguish timeout from decode failure, so the disk store's non-raise mode no longer runs a second full-budget frame-0 decode after a hung representative decode (which would have doubled an adversarial upload's hold on a request worker). - Correct two overclaims: the probe docstring no longer says acceptance semantics are unchanged (they are strictly wider - a file with a corrupt frame 0 but a decodable ~1s frame is now accepted), and it proves 'a decodable frame', not 'a decodable first frame'. - Two new tests pin the timeout behavior in both modes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014xFbHnmFTLsHE9e1PAdvme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #195 (
feat/video-ingest-transcode) — merge that first; this follows cleanly.Why
Frame 0 is a poor thumbnail source: generated videos routinely fade in from black, and #195's audio-only uploads render their synthesized waveform track's first frame from a near-empty audio window — every audio upload lands in the gallery as an undistinguished black tile.
What
representative_thumbnail_frame_index(duration, fps): ~1 s into the clip, capped at its midpoint so short clips still resolve to a real frame; unknown/degenerate metadata degrades to frame 0; unknown fps assumes 24 (the models' native rate and the waveform track's rate).extract_representative_video_frame(...): decodes that frame, falling back to frame 0 when the index has no decodable frame (container metadata is untrusted — overstated duration/fps must not cost the thumbnail). A timeout is never retried in either mode — the helper distinguishes timeout from decode failure internally — so an adversarial upload cannot double its hold on a request worker.duration/fpspassed down from the video service. The copy path still reuses the source's existing thumbnail; existing thumbnails are not regenerated.Testing
<video>poster is the only frame-semantic consumer and self-corrects onloadedmetadata; the waveform wrap's probed duration/fps are real, so the fix genuinely engages for audio uploads.🤖 Generated with Claude Code
https://claude.ai/code/session_014xFbHnmFTLsHE9e1PAdvme