Add per-step resilience and notifications across all video pipeline scripts
Each pipeline now saves intermediate files permanently before the step most likely to fail, so a partial failure leaves a recoverable artifact: - daily_sunrise_video.sh: speed-adjusted video (*-sped.mp4) survives if the drawtext overlay step fails; deleted automatically on success - montage-mvt.sh: speed-adjusted video (*-Sped.mp4) survives if the music-mux + attribution overlay step fails; deleted on success - 4-seasons.sh / montage-mvt.sh / year-end-join.sh: explicit ffmpeg error handling with targeted notify.sh calls naming the failed step and the surviving artifact path - montage-mvt.sh / 4-seasons.sh / year-end-join.sh: clip-duration-sum vs music-duration drift check warns when cumulative float error exceeds 2 s https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
+19
-3
@@ -32,6 +32,7 @@ concat_list=$(mktemp --suffix=.txt)
|
||||
trap 'rm -f "$concat_list"' EXIT
|
||||
|
||||
missing=0
|
||||
total_expected_dur=0
|
||||
for season in Winter Spring Summer Autumn; do
|
||||
for mvt in 1 2 3; do
|
||||
mvt_dir="$year_dir/$season/Mvt$mvt/montage"
|
||||
@@ -41,11 +42,14 @@ for season in Winter Spring Summer Autumn; do
|
||||
echo "WARNING: missing montage for $season Mvt$mvt ($mvt_dir)"
|
||||
missing=$((missing + 1))
|
||||
else
|
||||
echo " $season Mvt$mvt → $(basename "$f")"
|
||||
d=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$f")
|
||||
total_expected_dur=$(echo "scale=3; $total_expected_dur + $d" | bc)
|
||||
echo " $season Mvt$mvt → $(basename "$f") (${d}s)"
|
||||
printf "file '%s'\n" "$f" >> "$concat_list"
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "Expected total duration: ${total_expected_dur}s ($(echo "scale=1; $total_expected_dur/60" | bc) min)"
|
||||
|
||||
found=$(wc -l < "$concat_list")
|
||||
echo "$found of 12 movements found ($missing missing)"
|
||||
@@ -63,14 +67,26 @@ fi
|
||||
output_file="$year_dir/${CAM_NAME}-${ASTRO_YEAR}.mp4"
|
||||
echo "Output: $output_file"
|
||||
|
||||
ffmpeg -loglevel warning \
|
||||
if ! ffmpeg -loglevel warning \
|
||||
-f concat -safe 0 -i "$concat_list" \
|
||||
-c copy -y "$output_file"
|
||||
-c copy -y "$output_file"; then
|
||||
"$SCRIPT_DIR/notify.sh" "FAILED: year-end join $CAM_NAME $ASTRO_YEAR" \
|
||||
"ffmpeg concat failed — the 12 movement montages are still intact" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
total_dur=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$output_file")
|
||||
total_min=$(echo "scale=1; $total_dur / 60" | bc)
|
||||
echo "Done: $output_file (${total_min} min)"
|
||||
|
||||
# Sanity-check actual vs expected duration
|
||||
dur_drift=$(echo "scale=3; $total_dur - $total_expected_dur" | bc | sed 's/^-//')
|
||||
if awk "BEGIN{exit !($dur_drift > 2.0)}"; then
|
||||
echo "WARNING: output ${total_dur}s differs from expected ${total_expected_dur}s by ${dur_drift}s"
|
||||
"$SCRIPT_DIR/notify.sh" "WARNING: year-end duration drift $CAM_NAME $ASTRO_YEAR" \
|
||||
"Output ${total_dur}s vs expected ${total_expected_dur}s (drift ${dur_drift}s)" || true
|
||||
fi
|
||||
|
||||
# ── Notify ────────────────────────────────────────────────────────────────────
|
||||
"$SCRIPT_DIR/notify.sh" \
|
||||
"Four Seasons $ASTRO_YEAR complete" \
|
||||
|
||||
Reference in New Issue
Block a user