]> purplebirdman git - video-burn.git/commitdiff
Initial version of script
authorClifton Palmer <clifton.james.palmer@protonmail.com>
Fri, 30 May 2025 10:03:18 +0000 (13:03 +0300)
committerClifton Palmer <clifton.james.palmer@protonmail.com>
Fri, 30 May 2025 10:03:18 +0000 (13:03 +0300)
add-audio-to-video.sh [new file with mode: 0755]

diff --git a/add-audio-to-video.sh b/add-audio-to-video.sh
new file mode 100755 (executable)
index 0000000..e03bfda
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+input_video=$1
+input_audio=$2
+
+if [[ -z "$1" ]] || [[ -z "$2" ]]
+then
+       echo Invalid input
+       echo "\"$0 <input video> <input audio>\""
+       exit 1
+fi
+
+tmp_video=tmp$$.mp4
+ratio=0.65
+
+# make video about the same length as the audio
+ffmpeg \
+       -i $input_video \
+       -filter:v "setpts=${ratio}*PTS" \
+       $tmp_video
+
+# adds audio to video,
+# compresses audio
+ffmpeg \
+       -i $tmp_video \
+       -i $input_audio \
+       -c:v copy \
+       -map 0:v:0 \
+       -map 1:a:0 \
+       -c:a aac \
+       -b:a 192k \
+       output.mp4
+
+
+[[ -f $tmp_video ]] && rm $tmp_video