#!/bin/bash
if [ -z "$1" ]
then
	echo "Usage $0 file[.usm]"
fi

root=$(dirname ${BASH_SOURCE-$0})
fn=$(basename $1 .usm)
ls=$(ls -v $fn*.usm)
rm -f $fn.txt

for i in $ls; do
  bn=$(basename $i .usm)
  $root/usm2webm.sh $bn
  echo "file '$bn.webm'" >> $fn.txt
done

ext="webm"

/usr/bin/ffmpeg -loglevel warning -f concat -i $fn.txt -c copy $fn"_m."$ext

for i in $ls; do
  bn=$(basename $i .usm)
  rm $bn.webm
done
rm $fn.txt

