Skip to content

fix: reduce recording verification work and repeated transfers - #2232

Merged
richiemcilroy merged 6 commits into
mainfrom
codex/efficient-recording-verification
Sep 7, 2026
Merged

fix: reduce recording verification work and repeated transfers#2232
richiemcilroy merged 6 commits into
mainfrom
codex/efficient-recording-verification

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Sep 7, 2026

Copy link
Copy Markdown
Member

Large recordings currently decode both the source and the remuxed output, and can repeat transfers after transient failures. This adds a preservation proof over encoded packet bytes, codec configuration and timing so compatible recordings need one complete output decode. The existing decoded-source verification remains the fallback for unsupported container timing. Actual packet changes and corrupt output still fail closed. The remux now explicitly preserves the stored final audio packet duration, avoiding FFmpeg nominal-duration substitution that otherwise forces the slow fallback. Audio metadata inspection runs in a bounded, cancellable subprocess; real blocked-file tests verify cancellation and deadline cleanup.

Pinned Drive downloads and remote output checksum reads resume from the last verified byte within a bounded attempt budget. Decode progress advances from real frames, stalled decoders are terminated, and worker logs record verification duration and method. Upload identity checks, ownership fences and publication receipts remain in place.

Validation:

  • Scoped macOS tests: 163 passed, one opt-in performance test skipped; final affected-scope rerun: 121 passed, one skipped.
  • Final scoped production-image Linux tests with networking disabled, two CPUs and 2 GB memory: 181 verification, route and media utility tests passed, including a real remux of the two-minute 1080p performance case (6.5 seconds for packet proof plus complete decode).
  • Six complete cached production recordings passed remux, complete output decode and source-preservation checks in that Linux container; the 26.5-minute case completed in 44 seconds. Originals were mounted read-only. Separately, bounded beginning/end audio fragments from the large blocked recordings were downloaded directly from Drive to check final-packet preservation without retransferring their full videos.
  • Scoped Biome, production-source TypeScript check and git diff check passed. The full media-server TypeScript configuration has four existing errors in untouched test files.

This changes only the media server; no PlanetScale migration or Vercel function changes are required. It does not add durable checkpoints across worker restarts. Production deployment and recovery of the remaining large recordings still need live verification after CI and review.

Greptile Summary

This PR reduces recording verification work by proving preservation of encoded packet content, codec configuration, and timing before performing one complete output decode. It also preserves terminal audio duration during remuxing, resumes interrupted transfers and checksum reads, bounds retries and decoder stalls, and improves verification progress and logging.

  • Moves potentially stalled audio-tail inspection into a cancellable Bun subprocess.
  • Preserves the final source audio packet duration during FFmpeg remuxing.
  • Adds packet-level source-preservation verification with decoded-source fallback.
  • Resumes Drive downloads and remote verification reads from verified offsets.
  • Adds coverage for cancellation, malformed audio, transfer resumption, packet preservation, and error classification.

Confidence Score: 5/5

The PR appears safe to merge with no actionable new defects identified.

The latest changes replace potentially uninterruptible in-process audio inspection with a managed subprocess that is killed and joined on cancellation, while the supported Bun deployments retain and can execute the helper TypeScript file. The three previous findings were manually resolved without explanatory replies and therefore are not outstanding.

Important Files Changed

Filename Overview
apps/media-server/src/lib/recording-packet-proof.ts Adds cancellable subprocess-based audio inspection and packet-level preservation proofs over media content, configuration, and timing.
apps/media-server/src/lib/recording-audio-timing.ts Adds a standalone Bun helper that reads final audio-packet metadata while allowing the parent process to enforce cancellation.
apps/media-server/src/lib/recording-verification.ts Adds packet-bound remux verification, frame-based progress, decoder-stall handling, and resumable remote checksum verification.
apps/media-server/src/lib/media-video.ts Preserves stored terminal audio duration during remuxing and propagates existing cancellation reasons.
apps/media-server/src/lib/media-transfer.ts Retains downloaded bytes and resumes transfers across bounded transient request failures.
apps/media-server/src/routes/video.ts Integrates the optimized verification flow and records its method, duration, progress, and corrected failure classification.

Reviews (5): Last reviewed commit: "fix: terminate stalled audio timing insp..." | Re-trigger Greptile

Comment thread apps/media-server/src/routes/video.ts Outdated
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/media-server/src/routes/video.ts
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/media-server/src/lib/recording-packet-proof.ts Outdated
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy
richiemcilroy merged commit 84e13f2 into main Sep 7, 2026
29 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.

1 participant