#!/bin/bash

# delay the audio by using the same video file as two inputs
# for ffmpeg, one offset by $1 seconds. Take the video of the
# first, the audio of the offset one. Negative offsets are ok.

set -eu

if [ "$#" -ne 2 ]; then
  echo "USAGE: $0 DELAY FILE"
  exit 1
fi

fullpath="$2"
source fileextensions

cd "$dir"
ffmpeg -i "$filename.$extension" -itsoffset "$1" -i "$filename.$extension" -map 0:v -map 1:a -c copy "$filename""_delayed.$extension"