Fix overlay vertical text; test-sunrise captures fresh RTSP frames

Overlay fix (both scripts):
  Switch from text='...\n...' to drawtext's textfile= option. Writing
  each character on its own line eliminates the \n escape ambiguity in
  ffmpeg's filter-string single-quote parser, which was causing 'n' to
  appear literally instead of as a line break.

test-sunrise.sh redesign:
  Now captures NUM_FRAMES fresh RTSP frames (120s at default interval)
  at run time instead of reading pre-existing frames from the capture
  directory. The RTSP URL must be set in .env — the script fails early
  with a clear message if it is not.

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
Claude
2026-04-21 17:14:17 +00:00
parent eba8ddd550
commit f3839ce1cf
2 changed files with 74 additions and 55 deletions
+12 -7
View File
@@ -72,7 +72,8 @@ fi
temp_list=$(mktemp --suffix=.txt)
raw_video=""
temp_audio=""
trap 'rm -f "$temp_list" "$raw_video" "$temp_audio" 2>/dev/null || true' EXIT
temp_text=""
trap 'rm -f "$temp_list" "$raw_video" "$temp_audio" "$temp_text" 2>/dev/null || true' EXIT
find "$image_dir" -type f -name "*.jpg" | sort | while read -r img; do
img_sec=$(time_to_seconds "$(basename "$img" .jpg)")
@@ -143,13 +144,17 @@ echo "Speed-adjusted: ${sped_dur}s (saved — overlay still pending)"
SR_TIME=$(echo "$sunrise_time_local" | cut -d'-' -f1,2 | tr '-' ':')
DT=""
if [ "${SUNRISE_OVERLAY_ENABLED:-true}" = "true" ]; then
SR_VERT="${SR_TIME:0:1}\\\\n${SR_TIME:1:1}\\\\n${SR_TIME:2:1}\\\\n${SR_TIME:3:1}\\\\n${SR_TIME:4:1}"
DT="drawtext"
[ -n "$FONT" ] && DT="${DT}=fontfile='${FONT}'" || DT="${DT}"
DT="${DT}:text='${SR_VERT}'"
temp_text=$(mktemp --suffix=.txt)
printf '%s\n%s\n%s\n%s\n%s' \
"${SR_TIME:0:1}" "${SR_TIME:1:1}" "${SR_TIME:2:1}" "${SR_TIME:3:1}" "${SR_TIME:4:1}" \
> "$temp_text"
if [ -n "$FONT" ]; then
DT="drawtext=fontfile='${FONT}':textfile='${temp_text}'"
else
DT="drawtext=textfile='${temp_text}'"
fi
DT="${DT}:fontcolor=white@${SUNRISE_OVERLAY_OPACITY}"
DT="${DT}:fontsize=h/22"
DT="${DT}:line_spacing=4"
DT="${DT}:fontsize=h/22:line_spacing=4"
DT="${DT}:x=w-tw-18:y=(h-th)/2"
DT="${DT}:shadowcolor=black@0.55:shadowx=1:shadowy=1"
fi