From: Clifton Palmer Date: Fri, 30 May 2025 10:03:18 +0000 (+0300) Subject: Initial version of script X-Git-Url: http://git.purplebirdman.com/video-burn.git/commitdiff_plain/185c619fbfb27dadaa2310be26c31e492b964330 Initial version of script --- 185c619fbfb27dadaa2310be26c31e492b964330 diff --git a/add-audio-to-video.sh b/add-audio-to-video.sh new file mode 100755 index 0000000..e03bfda --- /dev/null +++ b/add-audio-to-video.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +input_video=$1 +input_audio=$2 + +if [[ -z "$1" ]] || [[ -z "$2" ]] +then + echo Invalid input + echo "\"$0 \"" + 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