Skip to content

Scanner: flag files with import-time problems that break playback #222

Description

@benders

Problem

Some files in the library have embedded-metadata pathologies that cause subtle playback failures — stalls, skips, or transcode breakage — that look like network or server bugs but are actually file-level issues. We need scanner-side detection so we can see how widespread the problem is before deciding whether to mitigate at stream time, rewrite on disk, or just hand-fix the offenders.

Known cases

1. Oversized embedded cover art

  • Example: /music/Other/Led Zeppelin/Led Zeppelin [Box Set]/4-13 I'm Gonna Crawl.mp3
    • Audio: MP3 256kbps, 5:31 (~10.6 MB expected)
    • Actual file: 60 MB
    • Embedded PNG: 3195×3111, 16-bit RGB, 49.6 MB
  • Same album, 2-09 D'yer Mak'er.mp3: 58 MB file, ~50 MB PNG.
  • Symptom: track skips during Vibrdrome playback over cellular. Navidrome must seek past the giant ID3v2 frame; client buffer underruns and gives up.
  • Heuristic: file_size / (duration * audio_bitrate/8) > 1.5, or embedded_art_bytes > 2 MB.

2. MJPEG (video-stream) cover art

  • Example: /music/Other/The Crystal Method/Vegas/*.mp3 — cover is a mjpeg 600×600 video stream, not a png/mjpeg image attachment.
  • Example: /music/CD Rips/Various Artists/Fear & Loathing in Las Vegas [Original Soundtrack]/*.flac — same pattern, 500×500 mjpeg.
  • Symptom: transcode pipelines that don't explicitly -map 0:a try to re-encode the cover too, breaking the stream.
  • Heuristic: any non-audio stream with codec_type=video and codec_name=mjpeg (or png embedded as video stream).

3. Other candidate checks worth including

  • Bit-rate / duration mismatch: declared duration doesn't match audio frame count (the FLAC end-early class, issue FLAC songs end early #34).
  • Multiple audio streams in one container.
  • Missing or malformed ID3 (no title/artist tags).
  • Sample-rate / channel-layout oddities that break opus transcode (e.g. >2 channels, non-44.1/48kHz).
  • Truncated files — last-frame decode fails.

Proposal

  1. Extend the scanner to compute per-file metadata via ffprobe and record:
    • embedded_art_bytes, embedded_art_codec, embedded_art_dimensions
    • extra_video_streams count
    • declared_vs_decoded_duration_delta
    • audio_stream_count
  2. Persist a media_file_problems table (or column flags on media_file) with one row per detected issue + severity.
  3. Surface a "Library health" admin view listing affected files grouped by issue type.
  4. No runtime mitigation in this issue — visibility first. Mitigation (stream-time strip vs. on-disk rewrite) is a follow-up once we know the blast radius.

Acceptance

  • Re-scanning the live library surfaces the two Zeppelin Box Set tracks (oversized PNG), The Crystal Method Vegas, and the Fear & Loathing soundtrack (mjpeg cover) as flagged.
  • Admin UI lists problem files with the specific issue and a one-line remediation hint.
  • Docs: add a section to docs/pitfalls.md linking the detector to the symptoms it explains.

Refs

  • Investigation that surfaced this: cellular playback skips on I'm Gonna Crawl and D'yer Mak'er 2026-05-22, traced to ~50 MB embedded PNGs.
  • Related: FLAC songs end early #34 (FLAC songs end early) — duration/decoded-length mismatch fits this detector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions