Video Audio Merge

Script to use FFMpeg to replace the audio stream within a video, e.g. for when you have carried out editing of an Audio stream with Audacity and then want to merge it back with the original Video.

Requires:

#!/bin/bash
# Video and Audio merging script written by QuidsUp
# Depends on ffmpeg
# Takes video.mkv and video.flac then outputs video-processed.mkv
# Usage: vidmerge.sh video
# (Note lack of .extension)

input_file=""
output_file=""
folder=$(pwd)

if [[ ! $1 ]]; then
  echo "No file specified"
  exit 1
fi

input_file=$1
output_file="$folder/$input_file-processed.mkv"

if [ ! -e "${input_file}.mkv" ]; then
  echo "Missing Video"
  exit 1
fi
if [ ! -e "${input_file}.flac" ]; then
  echo "Missing Audio"
  exit 1
fi

ffmpeg -i "$input_file.flac" -i "$input_file.mkv" -c copy "$output_file"
  
echo "Complete"


Back     Download