#!/usr/bin/env bash
# overlay.sh <overlay-image>

set -e

IMG="$1"
[ -z "$IMG" ] && { echo "Usage: $0 overlay.png"; exit 1; }

ffmpeg -y -i base.mp4 -i "$IMG" \
	-filter_complex "[1:v]scale=1059:529:force_original_aspect_ratio=decrease[ov];[0:v][ov]overlay=306:540-h:enable='gte(n\,159)'" \
	-af loudnorm=I=-16:TP=-1.5:LRA=11 \
	-c:v libx264 -c:a aac -b:a 192k out.mp4
