blob: 2d2320b564923bef264284e0929cbb77c000bb15 (
plain) (
tree)
|
|
#!/usr/bin/env bash
# {{ ansible_managed }}
# Mix in the normalized audio
# Usage: remux.sh $input_video_or_slug
with_suffix() {
echo "$input_video" | sed "s/--\(main\|reencoded\|original\).webm\$/--$1/"
}
input_video="$1"
if [ ! -f $input_video ]; then
# treat it as a slug
input_video=$(get-file-prefix $1)--reencoded.webm
fi
input_audio="$(with_suffix "normalized.opus")"
output_video="$(with_suffix "final.webm")"
main_video="$(with_suffix "main.webm")"
main_subs="$(with_suffix "main.vtt")"
if cat $main_subs | head -1 | grep captioned; then
$subs = "-i $main_subs"
fi
command="$(cat<<EOF
ffmpeg -y -i "$input_video" -i "$input_audio" $subs -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 "$output_video" &&
cp "$output_video" "$main_video" &&
if [[ -f "$main_subs" ]]; then touch -m "$main_subs"; fi
EOF
)"
printf "input: %s\ncomputed output: %s\nrelated main: %s\n\n" "$input_video" "$output_video" "$main_video"
printf "Produced incantation:\n%s\n\n" "$command"
if [ -z "$CONFIRMED" ]; then
eval "$command"
else
while true;
do
read -r -p "Run it? y/n " -n 1 -r response
if [[ $response =~ ^([yY])$ ]]; then
eval "$command"
exit 0
else
printf "\nExiting\n"
exit 3
fi
done
fi
|