From e76eeba60e8740ee2b8707476e59e2a4bf7296a9 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Wed, 17 Dec 2025 01:26:17 -0500 Subject: [PATCH] Fix chapter detection in video probing Added -show_chapters flag to ffprobe command to retrieve chapter information. Parse chapters from JSON output and set HasChapters field when chapters are present. Files with chapters will now correctly show 'Chapters: Yes' in the file information display. --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index 7708dd1..4330cdc 100644 --- a/main.go +++ b/main.go @@ -9160,6 +9160,7 @@ func probeVideo(path string) (*videoSource, error) { "-print_format", "json", "-show_format", "-show_streams", + "-show_chapters", path, ) utils.ApplyNoWindow(cmd) @@ -9194,6 +9195,9 @@ func probeVideo(path string) (*videoSource, error) { AttachedPic int `json:"attached_pic"` } `json:"disposition"` } `json:"streams"` + Chapters []struct { + ID int `json:"id"` + } `json:"chapters"` } if err := json.Unmarshal(out, &result); err != nil { return nil, err @@ -9219,6 +9223,13 @@ func probeVideo(path string) (*videoSource, error) { src.HasMetadata = true } } + + // Check for chapters + if len(result.Chapters) > 0 { + src.HasChapters = true + logging.Debug(logging.CatFFMPEG, "found %d chapter(s) in video", len(result.Chapters)) + } + // Track if we've found the main video stream (not cover art) foundMainVideo := false var coverArtStreamIndex int = -1