stuff/dhcp2024/render.sh

30 lines
894 B
Bash
Raw Permalink Normal View History

2024-10-31 07:26:28 +01:00
#!/bin/bash
set -euxo pipefail
INTRO="$1"
RECORDING="$2"
OUTRO="${3:-intros/outro_ccbysa.mkv}"
START_SECONDS="$3"
STOP_SECONDS="$4"
DURATION_SECONDS=$(($STOP_SECONDS - $START_SECONDS))
FADEOUT_SECONDS=$(($DURATION_SECONDS - 1))
ffmpeg -i "$INTRO" \
-ss $START_SECONDS -t $DURATION_SECONDS -i "$RECORDING" \
-i "$OUTRO" -filter_complex \
"[1:v:0]fade=t=in:st=0:d=0.2[x];[x]fade=t=out:st=$FADEOUT_SECONDS:d=1.0[y];\
[1:a:0]afade=t=in:st=0:d=0.2[a];[a]afade=t=out:st=$FADEOUT_SECONDS:d=1.0[b];\
[b]dynaudnorm[bd];\
[0:v:0][0:a:0]\
[y][bd]\
[2:v:0][2:a:0]\
concat=n=3:v=1:a=1\
[v][a0]" \
-map '[v]' -map '[a0]' \
-c:a aac -b:a 192k \
-c:v libx264 -threads 0 -pix_fmt yuv420p -crf 18 -profile:v high -level 4.1 -disposition default \
-metadata:s:a:0 language=native \
"rendered_recordings/$(basename -s .mp4 ${INTRO})_$(basename -s .mkv ${RECORDING})_COMBINED.mkv"