#! /bin/bash
# Last edited on 2021-08-03 23:12:37 by jstolfi

ifile="$1";  shift

ext="${ifile##*.}"
if [[ ( "/${ext}" != "/MTS" ) && ( "/${ext}" != "/mts" ) ]]; then
  echo "** invalid extension \"${ext}\"" 1>&2; exit 1
fi

ofile="${ifile%%.*}.mkv" 

ffmpeg \
  -i ${ifile} \
  -avoid_negative_ts make_non_negative \
  -scodec copy \
  -acodec copy \
  -vcodec copy \
  -f matroska \
  ${ofile}

touch -r ${ifile} ${ofile}
