diff --git a/daily_sunrise_video.sh b/daily_sunrise_video.sh index bb0908a..69b7983 100755 --- a/daily_sunrise_video.sh +++ b/daily_sunrise_video.sh @@ -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=$(echo "scale=3; $SUNRISE_TARGET_SECS * 0.085" | bc) +fade_out=$(echo "scale=3; $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