Encoding MTS files with NvENC

#!/bin/bash

# merge more mts file in one and encode it
# to obtain 1600x900 x264/aac file

# detect anctual folder
actualdir="`pwd`"

# check for folder path
if [ -z "$1" ]; then
    echo -e "Nessun argomento trovato !!!\nDevi specificare la path della cartella degli MTS da unire\n"
    exit 1
fi

# move into mts folder path
cd "$1"
FILES=`ls -1 *.MTS`
FILESVAR=""

# concat of MTS files name
for i in $FILES ; do
  FILESVAR="$FILESVAR$i|"
done

# encoding command generation
ffmpeg \
  -threads 4 \
  -i "concat:$FILESVAR" \
  -i /file/path/for/watermark.png \
  -filter_complex "[0:v]yadif, scale=-1:900[b];[b][1:v]overlay=x=(main_w-overlay_w-16):y=(main_h-overlay_h-16)" \
  -vcodec h264_nvenc \
  -preset:v llhq \
  -profile:v high \
  -level:v 5 \
  -rc:v ll_2pass_quality \
  -qmin:v 28 \
  -qmax:v 52 \
  -acodec aac \
  -ab 320k \
  -cutoff 22050 \
  -sn out.mkv




# return in first folder
cd $actualdir