diff options
Diffstat (limited to 'roles/prerec/templates/remux.sh')
-rwxr-xr-x | roles/prerec/templates/remux.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/roles/prerec/templates/remux.sh b/roles/prerec/templates/remux.sh new file mode 100755 index 0000000..c378133 --- /dev/null +++ b/roles/prerec/templates/remux.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# {{ ansible_managed }} +# Mix in the normalized audio +# Usage: remux.sh $input_video + +with_suffix() { + echo "$input_video" | sed "s/--\(reencoded\|original\).webm\$/--$1/" +} + +input_video="$1" +input_audio="$(with_suffix "normalized.opus")" +output_video="$(with_suffix "final.webm")" +main_video="$(with_suffix "main.webm")" +main_subs="$(with_suffix "main.vtt")" + +command="$(cat<<EOF +ffmpeg -i "$input_video" -i "$input_audio" -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" + +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 |