Skip to content

feat(scan): probe & store total video/audio duration at scan time#307

Merged
detain merged 1 commit into
masterfrom
feat/scan-probe-duration
Jun 23, 2026
Merged

feat(scan): probe & store total video/audio duration at scan time#307
detain merged 1 commit into
masterfrom
feat/scan-probe-duration

Conversation

@detain

@detain detain commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Why

The web player's scrubber starts with a tiny total length that grows as the file streams, because duration was only probed lazily at transcode time. Seeking before the playhead reaches a point was unreliable. The user wants the full length known up front.

What

  • MediaScanner now probes each time-based file's total duration via the existing FfmpegRunner::probe() as it is indexed and stores it under metadata_json['duration_seconds'] — the field MediaItemShaper already exposes to the API as duration and the player reads.
  • Probes only video/movie/episode/audio; never image/book/photo.
  • Backfill: on re-scan, already-indexed items missing a positive duration get probed and updated (preserving other metadata).
  • Matches TranscodeManager::persistProbedDuration() key/type/(int) round((float)) rounding so the scan- and transcode-time paths agree.
  • Probe failures are caught and never abort a scan.
  • Wired FfmpegRunner into the MediaScanner autowire definition.

Tests

7 new MediaScannerTest cases (mocked FfmpegRunner): new-video populated, audio probed, image/book never probed, null/throw does not abort, re-scan backfill, no re-probe when present. Full Unit/Media suite green (930 tests).

Verify

phpcs PSR-12 clean · phpstan L9 [OK] · phpunit green.

🤖 Generated with Claude Code

Probe each time-based file's total duration via ffprobe as it is indexed
and store it under metadata_json['duration_seconds'] (the field the API
already exposes as 'duration' and the player's scrubber reads). Previously
duration was only probed lazily at transcode time, so the scrubber length
grew as the stream/transcode manifest filled and seeking was unreliable.

- MediaScanner: optional FfmpegRunner dep; probe video/movie/episode/audio
  on create; backfill missing duration for already-indexed items on re-scan.
- Matches TranscodeManager::persistProbedDuration key/type/rounding so both
  paths agree; probe failures are caught and never abort a scan.
- Wired FfmpegRunner into the MediaScanner autowire definition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@detain detain merged commit 245502e into master Jun 23, 2026
8 of 9 checks passed
@detain detain deleted the feat/scan-probe-duration branch June 23, 2026 16:30
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 medium · 5 minor

Alerts:
⚠ 8 issues (≤ 0 issues of at least minor severity)

Results:
8 new issues

Category Results
Comprehensibility 4 minor
CodeStyle 1 minor
Complexity 3 medium

View in Codacy

🟢 Metrics 41 complexity · 0 duplication

Metric Results
Complexity 41
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.89%. Comparing base (7cb6256) to head (5f1d6e9).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Media/Library/MediaScanner.php 79.16% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #307      +/-   ##
============================================
+ Coverage     58.87%   58.89%   +0.02%     
- Complexity    12524    12545      +21     
============================================
  Files           474      474              
  Lines         41195    41248      +53     
============================================
+ Hits          24252    24295      +43     
- Misses        16943    16953      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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