Chapter extraction during library sync (ffprobe) #5

Closed
opened 2026-07-12 05:47:43 +00:00 by GKaszewski · 0 comments
Owner

Parent

#2

What to build

During library sync, extract chapter markers from media files using ffprobe and store them on the MediaItem. The Chapter value object and the chapters field on MediaItem already exist (added during the restructure). The migration for the chapters column on library_items also exists.

Implement the ffprobe invocation: run ffprobe -v quiet -print_format json -show_chapters <source_uri>, parse the JSON output into Vec<Chapter>. Only probe items where content_type is Movie or duration_secs > 2700 (45 minutes) — don't waste time on short episodes.

The chapter extraction should happen in the library sync adapter. When a provider syncs items into the library, after fetching metadata, probe for chapters if the source URI is a local file path or a network URL that ffprobe can read. Store the extracted chapters as a JSON array in the chapters column.

Acceptance criteria

  • ffprobe JSON output is parsed into Vec<Chapter> (title, start_secs, end_secs)
  • Chapter extraction runs during library sync for items with duration > 45 minutes
  • Short items (episodes, shorts) are skipped — no ffprobe call
  • Chapters are stored as JSON in the library_items.chapters column
  • Test: parse a sample ffprobe JSON response into correct Chapter structs (pure function test, no real file needed)
  • Test: items under 45 minutes get an empty chapters vec
  • Graceful handling: if ffprobe is not installed or fails, the item gets empty chapters (no crash)

Blocked by

None — can start immediately

## Parent #2 ## What to build During library sync, extract chapter markers from media files using ffprobe and store them on the MediaItem. The Chapter value object and the `chapters` field on MediaItem already exist (added during the restructure). The migration for the `chapters` column on `library_items` also exists. Implement the ffprobe invocation: run `ffprobe -v quiet -print_format json -show_chapters <source_uri>`, parse the JSON output into `Vec<Chapter>`. Only probe items where `content_type` is Movie or `duration_secs > 2700` (45 minutes) — don't waste time on short episodes. The chapter extraction should happen in the library sync adapter. When a provider syncs items into the library, after fetching metadata, probe for chapters if the source URI is a local file path or a network URL that ffprobe can read. Store the extracted chapters as a JSON array in the `chapters` column. ## Acceptance criteria - [ ] ffprobe JSON output is parsed into `Vec<Chapter>` (title, start_secs, end_secs) - [ ] Chapter extraction runs during library sync for items with duration > 45 minutes - [ ] Short items (episodes, shorts) are skipped — no ffprobe call - [ ] Chapters are stored as JSON in the library_items.chapters column - [ ] Test: parse a sample ffprobe JSON response into correct Chapter structs (pure function test, no real file needed) - [ ] Test: items under 45 minutes get an empty chapters vec - [ ] Graceful handling: if ffprobe is not installed or fails, the item gets empty chapters (no crash) ## Blocked by None — can start immediately
GKaszewski added the ready-for-agent label 2026-07-12 05:47:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GKaszewski/k-tv#5