#!/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}"