Skip to content

Measure a video's length at upload, and a "Repair length" button for existing recordings - #85

Merged
davior merged 2 commits into
mainfrom
claude/dazzling-meitner-m2f8al
Nov 27, 2026
Merged

davior merged 2 commits into
mainfrom
claude/dazzling-meitner-m2f8al

Conversation

@davior

@davior davior commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

What

A browser's MediaRecorder (Gecko Notes' recordings) writes WebM as a live stream: no duration and no seek index, so ffprobe reports N/A. A 30-minute, 555 MB recording was stored with no length. The player showed 0:08, and Video Creator rendered the clip as a tenth of a second.

1. New uploads are measured (ingest/probe.py)

When the container has no duration, or one that implies an impossible bitrate (over 50 MB/s), probe() reads the end of the last packet from the packets themselves.

  • A believable header is never replaced by a shorter scan.
  • Stills are not scanned.
  • Healthy files pay nothing extra.

2. Existing recordings can be repaired (enrichment/remux.py)

The Info tab shows a Repair length button on a video or sound that has no stored length. It goes away once the repair has worked.

  • POST /api/assets/{id}/remux queues a remux job.
  • Same streams, same id: it rewrites the file with -c copy behind the same asset id. Nothing is re-encoded, so tags, clips, playlists, transcripts and projects carry on, and every timestamp stays where it was.
  • Safe ordering: the new file is written and checked before anything points at it.
    • Same tracks, and a length within 1.5 s or 2% of the original measured from its packets.
    • The row switches in one commit, and the old file is deleted last.
    • A failed, cancelled or mismatched repair leaves the original exactly as it was, with no stray files.
  • Guards: it is held off while a version or a cut is running on the file, and holds those off (and make-original, and asset delete) while it runs. One repair at a time per asset.
  • Generated versions (480p, 720p, …) are untouched, since they were made from the original's picture.

Tests

  • 15 backend tests in tests/test_remux.py, covering the route, the guards, the job on a real live-written WebM, failure and cancel leaving the file untouched, and the check.
  • 5 backend tests in tests/test_probe_duration.py.
  • 8 frontend tests in RepairLengthButton.test.tsx.
  • Frontend: lint clean, 534 tests pass, build typechecks.
  • The suite-dependent backend test files fail in my sandbox only because the private gecko-suite client could not be downloaded there (403); I used a local stub to import the app. The same 95 fail without this change. CI runs them with the real client.

Pairs with davior/gvc#65, which makes Video Creator handle a clip of unknown length.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V1geD3sZfGVJcKE4BJMvgo

A browser's MediaRecorder (Gecko Notes' recordings) writes WebM as a live
stream: no duration, no seek index, so ffprobe says N/A. probe() returned no
duration, and everything downstream handled a 30-minute recording differently
(a player showing 0:08, Video Creator giving the clip a tenth of a second).

When the container has no duration, or one that implies an impossible bitrate,
read the last packet's end from the packets themselves. A believable header is
never replaced by a shorter scan, and stills are not scanned.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1geD3sZfGVJcKE4BJMvgo
The upload fix measures new recordings, but the ones already in a library (browser
WebM written as a live stream) keep no duration and no seek index. Repair rewrites
the file with the same streams (-c copy, nothing re-encoded) and swaps it in behind
the same asset id, so tags, clips, playlists and projects carry on.

The new file is written and checked before anything points at it (same tracks, same
length as the original measured from its packets); the row switches in one commit; the
old file is deleted last. A failed, cancelled or mismatched repair leaves the original
exactly as it was. It is held off while a version or a cut is running on the file, and
holds those off while it runs.

POST /api/assets/{id}/remux queues the job; the button shows on the Info tab only while
the asset has no stored length, so it goes away when the repair has worked.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1geD3sZfGVJcKE4BJMvgo
@davior davior changed the title Measure a video's length from its packets when its header has none Measure a video's length at upload, and a "Repair length" button for existing recordings Nov 27, 2026
@davior
davior marked this pull request as ready for review November 27, 2026 06:45
@davior
davior merged commit 3cb9fd2 into main Nov 27, 2026
3 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.

2 participants