]> purplebirdman git - video-burn.git/blob - add-audio-to-video.sh
e03bfda84433079c4e63da6c28c6a7a3a111b3d8
[video-burn.git] / add-audio-to-video.sh
1 #!/bin/sh
2
3 input_video=$1
4 input_audio=$2
5
6 if [[ -z "$1" ]] || [[ -z "$2" ]]
7 then
8         echo Invalid input
9         echo "\"$0 <input video> <input audio>\""
10         exit 1
11 fi
12
13 tmp_video=tmp$$.mp4
14 ratio=0.65
15
16 # make video about the same length as the audio
17 ffmpeg \
18         -i $input_video \
19         -filter:v "setpts=${ratio}*PTS" \
20         $tmp_video
21
22 # adds audio to video,
23 # compresses audio
24 ffmpeg \
25         -i $tmp_video \
26         -i $input_audio \
27         -c:v copy \
28         -map 0:v:0 \
29         -map 1:a:0 \
30         -c:a aac \
31         -b:a 192k \
32         output.mp4
33
34
35 [[ -f $tmp_video ]] && rm $tmp_video