#!/bin/sh set -e filename=${1:-} audioname=$(printf "$filename" | sed "s/\(.*\).vtt/\1/") outdir=$(dirname "$filename")/utterances mkdir -p "$outdir" # given vtt what is original ext? ffmpeg_commands=$(grep "\-->" $filename | awk -F " " \ -v aname="$audioname" \ -v outdir="$outdir" \ '{print "ffmpeg -i "aname" -ss " $1 " -to " $3 \ " -metadata text_source=" aname ".vtt" \ " -vn -acodec copy " outdir "/" $1"_"$3 ".ogg"}') while read cline; do echo $cline && sleep 1; done <<< $ffmpeg_commands