Jellyfin merges <Base> - <variant>.mp4 music videos into one multi-version item — Behind the Music (61 files) and Top of the Pops (24 files) each land as a single ErsatzTV item #615

Closed
opened 2026-07-25 17:01:00 +02:00 by timothy · 2 comments
Owner

Found while doing the #487 folder-tag sweep. Not caused by that change — pre-existing, and it was invisible until the tag counts made per-folder ingestion measurable.

Symptom

After tagging every NFO and running a full Jellyfin scan + ErsatzTV library scan, two folders reconcile far short of their file count:

folder video files NFOs tagged Jellyfin items
Behind the Music 61 61 1
Top of the Pops 24 24 1
Cookin Soul 81 79 77

Every other folder reconciles exactly (The Midnight Special 271/271, Glastonbury Concerts 187/187, Vaporwave 204/204, …).

Root cause

Jellyfin's multi-version merging. Files sharing a base name before the - separator are folded into one item carrying N alternate MediaSources:

Behind the Music -> item "Behind The Music - S01E01 - Milli Vanilli"  MediaSources=61
Top of the Pops   -> item "Top of the Pops - 1976-04-08"               MediaSources=24
Cookin Soul       -> item "Beat Making MPC 2000XL ..."                 MediaSources=1   (normal)

The filenames are exactly the shape that triggers it:

  • Behind The Music - S01E01 - Milli Vanilli.mp4 (common base Behind The Music)
  • Top of the Pops - 1976-04-08.mp4 (common base Top of the Pops)

Why it matters for ErsatzTV

ErsatzTV only ever sees one media item per merged group, so:

  • collection 25 Behind the Music can hold 1 item, not 61
  • collection 18 Retro TV Music gets 1 Top of the Pops item instead of 24

Those channels will loop a single title. The tag data is correct; the item grouping upstream is not.

Options (none taken — needs an operator/content decision)

  1. Rename the media files so they don't share a base before - (e.g. Behind The Music S01E01 - Milli Vanilli.mp4). ~85 files on prod media. Most direct, but it is content-file work.
  2. Restructure as a TV library — Behind the Music and Top of the Pops genuinely are episodic series; a tvshows-typed library models them correctly, at the cost of them no longer being music videos in ErsatzTV.
  3. Disable version merging for the Music Videos library if Jellyfin exposes it for musicvideos collection type (unverified).

Leaning (1) for Top of the Pops (date-stamped, not really episodic) and (2) for Behind the Music (real SxxExx series), but that is a content-modelling call.

Resolved 2026-07-26: operator chose option 1 for BOTH folders — keep them as music videos, rename so the shared base is broken. See the closing record.

Boundary note

This is arguably media-management / content-sourcing territory rather than fork code (see CLAUDE.md → Project Boundaries). Filed here because it directly determines what two ErsatzTV collections can contain and was discovered under #487; move it if a timothy/media-management repo lands.

Done-when

  • An option above is chosen for each of the two folders — option 1 (rename) for both
  • Applied, library rescanned, per-folder item counts match file counts — Jellyfin Behind the Music 61/61, Top of the Pops 24/24, each with MediaSources == Items
  • Collections 18 + 25 re-populated to their true size — 25: 1 → 61, 18: 274 → 297 (all 24 ToTP)
  • Adversarial review passed — swept all 30 music-video folders: 0 remaining merged folders
Found while doing the #487 folder-tag sweep. **Not caused by that change** — pre-existing, and it was invisible until the tag counts made per-folder ingestion measurable. ## Symptom After tagging every NFO and running a full Jellyfin scan + ErsatzTV library scan, two folders reconcile far short of their file count: | folder | video files | NFOs tagged | Jellyfin items | |---|---|---|---| | `Behind the Music` | 61 | 61 | **1** | | `Top of the Pops` | 24 | 24 | **1** | | `Cookin Soul` | 81 | 79 | 77 | Every other folder reconciles exactly (`The Midnight Special` 271/271, `Glastonbury Concerts` 187/187, `Vaporwave` 204/204, …). ## Root cause Jellyfin's multi-version merging. Files sharing a base name before the ` - ` separator are folded into **one** item carrying N alternate `MediaSources`: ``` Behind the Music -> item "Behind The Music - S01E01 - Milli Vanilli" MediaSources=61 Top of the Pops -> item "Top of the Pops - 1976-04-08" MediaSources=24 Cookin Soul -> item "Beat Making MPC 2000XL ..." MediaSources=1 (normal) ``` The filenames are exactly the shape that triggers it: - `Behind The Music - S01E01 - Milli Vanilli.mp4` (common base `Behind The Music`) - `Top of the Pops - 1976-04-08.mp4` (common base `Top of the Pops`) ## Why it matters for ErsatzTV ErsatzTV only ever sees **one** media item per merged group, so: - collection **25 `Behind the Music`** can hold 1 item, not 61 - collection **18 `Retro TV Music`** gets 1 `Top of the Pops` item instead of 24 Those channels will loop a single title. The tag data is correct; the item grouping upstream is not. ## Options (none taken — needs an operator/content decision) 1. **Rename the media files** so they don't share a base before ` - ` (e.g. `Behind The Music S01E01 - Milli Vanilli.mp4`). ~85 files on prod media. Most direct, but it is content-file work. 2. **Restructure as a TV library** — `Behind the Music` and `Top of the Pops` genuinely *are* episodic series; a `tvshows`-typed library models them correctly, at the cost of them no longer being music videos in ErsatzTV. 3. **Disable version merging** for the `Music Videos` library if Jellyfin exposes it for `musicvideos` collection type (unverified). Leaning (1) for `Top of the Pops` (date-stamped, not really episodic) and (2) for `Behind the Music` (real `SxxExx` series), but that is a content-modelling call. **Resolved 2026-07-26: operator chose option 1 for BOTH folders** — keep them as music videos, rename so the shared base is broken. See the closing record. ## Boundary note This is arguably media-management / content-sourcing territory rather than fork code (see `CLAUDE.md` → Project Boundaries). Filed here because it directly determines what two ErsatzTV collections can contain and was discovered under #487; move it if a `timothy/media-management` repo lands. ## Done-when - [x] An option above is chosen for each of the two folders — **option 1 (rename) for both** - [x] Applied, library rescanned, per-folder item counts match file counts — Jellyfin `Behind the Music` **61/61**, `Top of the Pops` **24/24**, each with `MediaSources == Items` - [x] Collections 18 + 25 re-populated to their true size — **25: 1 → 61**, **18: 274 → 297** (all 24 ToTP) - [x] Adversarial review passed — swept **all 30** music-video folders: **0 remaining merged folders**
timothy added the bugjellyfinpriority: medium labels 2026-07-25 17:01:06 +02:00
timothy added the in-progress label 2026-07-26 00:25:32 +02:00
Author
Owner

Claiming — bundled with #617 (shared jellyfin label).

Operator decision taken: option 1 for both folders — rename the media files so they no longer share a base before -, keeping both as music videos in ErsatzTV. No library restructure, no TV-library move.

Plan: enumerate the actual files on the media host, produce a full rename map for review before executing anything, then rescan Jellyfin + the ErsatzTV library and reconcile per-folder item counts against file counts.

Claiming — bundled with #617 (shared `jellyfin` label). Operator decision taken: **option 1 for both folders** — rename the media files so they no longer share a base before ` - `, keeping both as music videos in ErsatzTV. No library restructure, no TV-library move. Plan: enumerate the actual files on the media host, produce a full rename map for review before executing anything, then rescan Jellyfin + the ErsatzTV library and reconcile per-folder item counts against file counts.
Author
Owner

Closing record

Outcome: Fixed on prod media. Operator chose option 1 for both folders — keep them as music videos and rename so no two files share a base before -. Renamed 170 files (85 videos + 85 paired NFOs) on jazz: Behind The Music - S01E01 - X.mp4 → Behind The Music S01E01 - X.mp4, Top of the Pops - 1976-04-08.mp4 → Top of the Pops 1976-04-08.mp4. No code change, so no PR.

Results:

before after
Jellyfin items — Behind the Music 1 (61 MediaSources) 61 (61 sources)
Jellyfin items — Top of the Pops 1 (24 MediaSources) 24 (24 sources)
Collection 25 Behind the Music 1 item 61
Collection 18 Retro TV Music 274, of which 1 ToTP 297, of which 24 ToTP
Channel 409 playout looped 1 title 61 distinct media items
Channel 403 playout no ToTP variety ToTP scheduled, distinct dates

Root cause: Jellyfin's multi-version merging groups by the filename base before - at resolver time, before NFO metadata is read. 61 files all beginning Behind The Music - collapsed into one item with 61 alternate MediaSources; ErsatzTV only ever syncs one media item per group. Breaking the shared base is sufficient — the NFO <title> values were left untouched (still Behind The Music - S01E01 - Milli Vanilli), so display titles are unchanged and merging still did not recur. That confirms grouping is filename-driven, not title-driven.

Decisions/conventions changed: none. This is content-file modelling, not fork code.

Reusable knowledge:

  • Jellyfin merges <Base> - <variant>.ext music videos into one multi-version item. The tell is MediaSources > 1 on an item — that ratio, not the raw item count, is the reliable detector. Any new folder whose files share a base before - will silently collapse.
  • MediaSources == Items distinguishes "merged" from "never ingested". Both look like "folder is short of its file count", but they need completely different fixes. Sweeping on this ratio found the merging was fully gone and surfaced a separate ingestion gap → filed as #640.
  • A renamed file is a delete+create to ErsatzTV, not a move. The old MediaItem ids (46937, 48249) were deleted by the rescan and manual collection membership went with them — collection 25 dropped to 0 before repopulation. Any rename of media backing a manual Collection must be followed by re-adding items and resetting affected playouts, or the channel silently empties.
  • ErsatzTV library ids are not Jellyfin library ids. Music Videos is 16 in ErsatzTV and e2c00f29… in Jellyfin; the ersatztv skill claimed 8. Scanning is POST /api/v1/libraries/{id}/scan — there is no PUT …/sync. Both corrected in #617/PR #639.
  • A non-recursive file count produces false gaps for nested folders. Concert Films looked like "1 file, 37 items" until counted recursively (37/37). Nearly reported as breakage.

Verification:

  • Rename executed with a per-file guard (mv -n, refuse if target exists): 170 renamed, 0 skipped, 0 failed; pre-checked 122→122 and 48→48 unique targets, zero clashes.
  • Disk after: 61 distinct bases for 61 videos, 24 for 24, zero files retaining the merging shape.
  • ErsatzTV rescan of library 16 to completion (~5 min); 0 items in State=1 (FileNotFound).
  • Collections and playouts verified by direct DB query, not just API 2xx — channel 409 rebuilt to 61 distinct media items.
  • Adversarial sweep of all 30 music-video folders: 0 with MediaSources > Items. The bug class is eliminated library-wide, not just in the two reported folders.

Deferred: ~25 files across 4 folders are on disk but never ingested by Jellyfin (HipHopHistoryGuy 19, Cookin Soul 4, Glastonbury Concerts 1, Vaporwave 1). Pre-existing, a different failure mode, and Cookin Soul's gap was already visible in this issue's own table. Filed as #640.

Docs updated: none required here (no fork code changed). The related skill-file corrections this work surfaced — ErsatzTV library ids, the scan endpoint — ship in #617 / PR #639.

## Closing record **Outcome:** Fixed on prod media. Operator chose **option 1 for both folders** — keep them as music videos and rename so no two files share a base before ` - `. Renamed **170 files** (85 videos + 85 paired NFOs) on jazz: `Behind The Music - S01E01 - X.mp4` → `Behind The Music S01E01 - X.mp4`, `Top of the Pops - 1976-04-08.mp4` → `Top of the Pops 1976-04-08.mp4`. No code change, so no PR. Results: | | before | after | |---|---|---| | Jellyfin items — `Behind the Music` | 1 (61 MediaSources) | **61** (61 sources) | | Jellyfin items — `Top of the Pops` | 1 (24 MediaSources) | **24** (24 sources) | | Collection 25 `Behind the Music` | 1 item | **61** | | Collection 18 `Retro TV Music` | 274, of which 1 ToTP | **297**, of which **24** ToTP | | Channel 409 playout | looped 1 title | **61 distinct** media items | | Channel 403 playout | no ToTP variety | ToTP scheduled, distinct dates | **Root cause:** Jellyfin's multi-version merging groups by the filename base before ` - ` at resolver time, before NFO metadata is read. 61 files all beginning `Behind The Music - ` collapsed into one item with 61 alternate `MediaSources`; ErsatzTV only ever syncs one media item per group. Breaking the shared base is sufficient — the NFO `<title>` values were left untouched (still `Behind The Music - S01E01 - Milli Vanilli`), so display titles are unchanged and merging still did not recur. That confirms grouping is **filename**-driven, not title-driven. **Decisions/conventions changed:** none. This is content-file modelling, not fork code. **Reusable knowledge:** - **Jellyfin merges `<Base> - <variant>.ext` music videos into one multi-version item.** The tell is `MediaSources > 1` on an item — that ratio, not the raw item count, is the reliable detector. Any new folder whose files share a base before ` - ` will silently collapse. - **`MediaSources == Items` distinguishes "merged" from "never ingested".** Both look like "folder is short of its file count", but they need completely different fixes. Sweeping on this ratio found the merging was fully gone *and* surfaced a separate ingestion gap → filed as #640. - **A renamed file is a delete+create to ErsatzTV, not a move.** The old MediaItem ids (46937, 48249) were **deleted** by the rescan and manual collection membership went with them — collection 25 dropped to **0** before repopulation. Any rename of media backing a manual `Collection` must be followed by re-adding items and resetting affected playouts, or the channel silently empties. - **ErsatzTV library ids are not Jellyfin library ids.** Music Videos is **16** in ErsatzTV and `e2c00f29…` in Jellyfin; the `ersatztv` skill claimed 8. Scanning is `POST /api/v1/libraries/{id}/scan` — there is no `PUT …/sync`. Both corrected in #617/PR #639. - **A non-recursive file count produces false gaps for nested folders.** `Concert Films` looked like "1 file, 37 items" until counted recursively (37/37). Nearly reported as breakage. **Verification:** - Rename executed with a per-file guard (`mv -n`, refuse if target exists): **170 renamed, 0 skipped, 0 failed**; pre-checked 122→122 and 48→48 unique targets, zero clashes. - Disk after: 61 distinct bases for 61 videos, 24 for 24, zero files retaining the merging shape. - ErsatzTV rescan of library 16 to completion (~5 min); **0 items in `State=1` (FileNotFound)**. - Collections and playouts verified by direct DB query, not just API 2xx — channel 409 rebuilt to 61 distinct media items. - **Adversarial sweep of all 30 music-video folders: 0 with `MediaSources > Items`.** The bug class is eliminated library-wide, not just in the two reported folders. **Deferred:** ~25 files across 4 folders are on disk but never ingested by Jellyfin (`HipHopHistoryGuy` 19, `Cookin Soul` 4, `Glastonbury Concerts` 1, `Vaporwave` 1). Pre-existing, a different failure mode, and `Cookin Soul`'s gap was already visible in this issue's own table. Filed as **#640**. **Docs updated:** none required here (no fork code changed). The related skill-file corrections this work surfaced — ErsatzTV library ids, the scan endpoint — ship in #617 / PR #639.
timothy removed the in-progress label 2026-07-26 00:46:58 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#615