sunrise: quicker audio fades, raise overlay, yesterday-audio fallback
- Shorten audio fade in/out to 0.3s so they fit comfortably in the 10s clip. - Lift the sunrise-time overlay by ~5% of frame height to clear the burnt-in timestamp on the source images. - When today's sunrise recording is missing, fall back to yesterday's clip before reaching for the library fallback.
This commit is contained in:
+19
-9
@@ -211,7 +211,7 @@ if [ "${SUNRISE_OVERLAY_ENABLED:-true}" = "true" ]; then
|
||||
fi
|
||||
DT="${DT}:fontcolor=yellow@${SUNRISE_OVERLAY_OPACITY}"
|
||||
DT="${DT}:fontsize=h/22:line_spacing=4"
|
||||
DT="${DT}:x=w-tw-18:y=h-th-18"
|
||||
DT="${DT}:x=w-tw-18:y=h-th-18-h*0.05"
|
||||
DT="${DT}:shadowcolor=black@0.55:shadowx=1:shadowy=1"
|
||||
fi
|
||||
|
||||
@@ -251,12 +251,21 @@ else
|
||||
audio_src="$cam_audio"
|
||||
echo "Audio: camera recording (centred on sunrise)"
|
||||
else
|
||||
library_dir="$SCRIPT_DIR/sunrise-sounds"
|
||||
if [ -d "$library_dir" ]; then
|
||||
random_file=$(find "$library_dir" -name "*.mp3" | shuf -n 1 2>/dev/null || true)
|
||||
if [ -n "$random_file" ]; then
|
||||
audio_src="$random_file"
|
||||
echo "Audio: library fallback $(basename "$audio_src")"
|
||||
# Yesterday fallback before library: keeps the clip on-site
|
||||
yesterday_date=$(date -d "yesterday" +%Y-%m-%d)
|
||||
yday_audio="${AUDIO_DIR:-$BASE_DIR/audio}/sunrise/$CAM_NAME/$yesterday_date/sunrise-audio.m4a"
|
||||
[ ! -f "$yday_audio" ] && yday_audio="$BASE_DIR/$CAM_NAME/$yesterday_date/sunrise-audio.m4a"
|
||||
if [ -f "$yday_audio" ]; then
|
||||
audio_src="$yday_audio"
|
||||
echo "Audio: yesterday's recording ($yesterday_date)"
|
||||
else
|
||||
library_dir="$SCRIPT_DIR/sunrise-sounds"
|
||||
if [ -d "$library_dir" ]; then
|
||||
random_file=$(find "$library_dir" -name "*.mp3" | shuf -n 1 2>/dev/null || true)
|
||||
if [ -n "$random_file" ]; then
|
||||
audio_src="$random_file"
|
||||
echo "Audio: library fallback $(basename "$audio_src")"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -279,7 +288,8 @@ if $TEST_MODE; then
|
||||
else
|
||||
final_video="$output_dir/$CAM_NAME-$current_date-daily-sunrise.mp4"
|
||||
fi
|
||||
fade_out=$(echo "scale=1; $SUNRISE_TARGET_SECS - 0.5" | bc)
|
||||
fade_dur=0.3
|
||||
fade_out=$(echo "scale=2; $SUNRISE_TARGET_SECS - $fade_dur" | bc)
|
||||
|
||||
# ── Step 3a: mix audio (video copied, not re-encoded) ────────────────────────
|
||||
work_video="$sped_video"
|
||||
@@ -291,7 +301,7 @@ if [ -n "$audio_src" ]; then
|
||||
if ffmpeg -loglevel warning \
|
||||
-i "$sped_video" \
|
||||
-ss "$audio_offset" -t "$SUNRISE_TARGET_SECS" -i "$audio_src" \
|
||||
-filter_complex "[1:a]afade=t=in:st=0:d=0.5,afade=t=out:st=${fade_out}:d=0.5[aout]" \
|
||||
-filter_complex "[1:a]afade=t=in:st=0:d=${fade_dur},afade=t=out:st=${fade_out}:d=${fade_dur}[aout]" \
|
||||
-map "0:v" -map "[aout]" \
|
||||
-c:v copy -c:a aac -b:a 128k \
|
||||
-y "$temp_audio"; then
|
||||
|
||||
Reference in New Issue
Block a user