unix4artists/ffmpeg/audio/audiovideo.sh

28 lines
603 B
Bash
Raw Normal View History

2021-05-08 16:53:26 +00:00
#!/bin/bash -e
#####################################################
#
# This script will combine the audio from one file and the
# video from another file.
#
# Usage: bash ffmpeg/audio/audiovideo.sh <input audio> <input video> <output video>
#
#####################################################
AUDIO="${1}"
VIDEO="${2}"
OUTPUT="${3}"
# Check if output file extension is .mkv
if [[ "${OUTPUT}" != *".mkv" ]]; then
echo "Please use an .mkv extension on your output file argument"
exit 1
fi
ffmpeg -i "${VIDEO}" \
-i "${AUDIO}" \
-c copy \
-map 0:v:0 \
-map 1:a:0 \
-shortest \
"${OUTPUT}"