Fix sunrise overlay vertical text and test-sunrise.sh pipeline bugs
- Overlay text was showing characters run together (e.g. '1n2n') because inside ffmpeg single-quoted filter text, \n is consumed as just 'n'. Fix: use \\\\n in bash double-quotes which stores \\n in the variable, which ffmpeg then parses as \n, which drawtext renders as a newline. Applied to both test-sunrise.sh (MID_VERT) and daily_sunrise_video.sh (SR_VERT, replacing the awk one-liner with the same bash approach). - test-sunrise.sh concat list was missing per-frame duration entries, causing 12 frames to encode as 0.48s (25fps default) and then slow down instead of compress. Fixed by writing 'duration INTERVAL' per frame so 12 frames × 10s = 120s raw → 12× compression to 10s. - Removed 2>/dev/null from audio ffmpeg call in test-sunrise.sh so capture failures are visible for diagnosis. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
@@ -143,7 +143,7 @@ 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=$(echo "$SR_TIME" | awk 'BEGIN{FS=""}{for(i=1;i<=NF;i++){printf "%s",$i; if(i<NF)printf "\\n"}}')
|
||||
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}'"
|
||||
|
||||
+13
-4
@@ -49,8 +49,11 @@ mid_hms=$(basename "$mid_frame" .jpg) # HH-MM-SS
|
||||
MID_TIME=$(echo "$mid_hms" | cut -c1-5 | tr '-' ':') # HH:MM
|
||||
echo "Mid-point frame: $mid_hms → overlay time: $MID_TIME"
|
||||
|
||||
# Vertical text: each character on its own line (matches daily_sunrise_video.sh)
|
||||
MID_VERT="${MID_TIME:0:1}\\n${MID_TIME:1:1}\\n${MID_TIME:2:1}\\n${MID_TIME:3:1}\\n${MID_TIME:4:1}"
|
||||
# Vertical text: each character on its own line.
|
||||
# Inside ffmpeg single-quoted text values, \ is an escape prefix so \n → n.
|
||||
# We need \\n so ffmpeg parses it as \n which drawtext renders as a newline.
|
||||
# In bash double-quotes \\\\n → \\n (the value stored in the variable).
|
||||
MID_VERT="${MID_TIME:0:1}\\\\n${MID_TIME:1:1}\\\\n${MID_TIME:2:1}\\\\n${MID_TIME:3:1}\\\\n${MID_TIME:4:1}"
|
||||
|
||||
# ── Font detection ────────────────────────────────────────────────────────────
|
||||
FONT=""
|
||||
@@ -74,7 +77,13 @@ TMP_AUDIO=$(mktemp --suffix=.m4a)
|
||||
cleanup() { rm -f "$TMP_LIST" "$TMP_RAW" "$TMP_SPED" "$TMP_AUDIO" 2>/dev/null || true; }
|
||||
trap cleanup EXIT
|
||||
|
||||
printf "file '%s'\n" "${frames[@]}" > "$TMP_LIST"
|
||||
# Write concat list with explicit duration per frame so raw video represents
|
||||
# real elapsed time: 12 frames × CAPTURE_INTERVAL seconds = ~2 minutes.
|
||||
# The final entry needs a duplicate without duration (ffmpeg concat requirement).
|
||||
for f in "${frames[@]}"; do
|
||||
printf "file '%s'\nduration %s\n" "$f" "${CAPTURE_INTERVAL:-10}"
|
||||
done >> "$TMP_LIST"
|
||||
printf "file '%s'\n" "${frames[-1]}" >> "$TMP_LIST"
|
||||
|
||||
# ── Step 1: raw video from frames ─────────────────────────────────────────────
|
||||
echo ""
|
||||
@@ -111,7 +120,7 @@ if [ -n "$RTSP_URL" ]; then
|
||||
-i "$RTSP_URL" \
|
||||
-t "$SUNRISE_TARGET_SECS" \
|
||||
-vn -c:a aac -b:a 64k \
|
||||
-y "$TMP_AUDIO" 2>/dev/null; then
|
||||
-y "$TMP_AUDIO"; then
|
||||
HAS_AUDIO=true
|
||||
echo " Audio: captured OK"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user