summaryrefslogtreecommitdiffstats
path: root/roles/prerec/templates/remux.sh
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2024-10-01 19:59:03 -0400
committerSacha Chua <sacha@sachachua.com>2024-10-01 19:59:03 -0400
commit2be81b299be9cad0b03495f2ea038a01969c6cb2 (patch)
tree6f798cdf8233d0c1079eaff3a52fd3bdabf8bdf7 /roles/prerec/templates/remux.sh
parenta50799ae2d27ea57f9f470a9ecfb06dd77499c34 (diff)
downloademacsconf-ansible-2be81b299be9cad0b03495f2ea038a01969c6cb2.tar.xz
emacsconf-ansible-2be81b299be9cad0b03495f2ea038a01969c6cb2.zip
Update for new ansible version
Diffstat (limited to '')
-rwxr-xr-xroles/prerec/templates/remux.sh41
1 files changed, 27 insertions, 14 deletions
diff --git a/roles/prerec/templates/remux.sh b/roles/prerec/templates/remux.sh
index c378133..2d2320b 100755
--- a/roles/prerec/templates/remux.sh
+++ b/roles/prerec/templates/remux.sh
@@ -1,20 +1,29 @@
#!/usr/bin/env bash
# {{ ansible_managed }}
# Mix in the normalized audio
-# Usage: remux.sh $input_video
+# Usage: remux.sh $input_video_or_slug
with_suffix() {
- echo "$input_video" | sed "s/--\(reencoded\|original\).webm\$/--$1/"
+ 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 -i "$input_video" -i "$input_audio" -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 "$output_video" &&
+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
@@ -23,14 +32,18 @@ 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
+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