From 1a2a7e337b0eea31e7e363a1c78ce98e1923fb46 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 11 Feb 2026 11:03:38 +0100 Subject: [PATCH] Fix concat tool: handle embedded album art and strip track numbers from chapters The m4a muxer doesn't support mjpeg as a regular video stream, causing concatenation to fail when inputs contain album art. Extract art separately and re-attach it with attached_pic disposition. Also strip leading track numbers (e.g. "01 ") from chapter titles. Co-Authored-By: Claude Opus 4.6 --- tools/concat_cassette.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/concat_cassette.sh b/tools/concat_cassette.sh index e685f35..8340596 100755 --- a/tools/concat_cassette.sh +++ b/tools/concat_cassette.sh @@ -74,9 +74,10 @@ for f in "${inputs[@]}"; do [ -z "$dur" ] && die "Could not read duration of: $f" dur_ms=$(awk "BEGIN { printf \"%d\", $dur * 1000 }") - # Chapter title from filename (strip path and extension) + # Chapter title from filename (strip path, extension, and leading track number) title=$(basename "$f") title="${title%.*}" + title=$(echo "$title" | sed 's/^[0-9][0-9]*[[:space:]._-]*//') end_ms=$((cumulative_ms + dur_ms)) cat >> "$metadata" </dev/null || true + # --- Concatenate --- -ffmpeg -y -f concat -safe 0 -i "$concat_list" -i "$metadata" \ - -map_metadata 1 -c copy -movflags +faststart "$output" 2>&1 +if [ -f "$art" ]; then + ffmpeg -y -f concat -safe 0 -i "$concat_list" -i "$metadata" -i "$art" \ + -map 0:a -map 2:v -map_metadata 1 -c copy \ + -disposition:v:0 attached_pic -movflags +faststart "$output" 2>&1 +else + ffmpeg -y -f concat -safe 0 -i "$concat_list" -i "$metadata" \ + -map 0:a -map_metadata 1 -c copy -movflags +faststart "$output" 2>&1 +fi # --- Summary ---