diff --git a/ts-to-mkv.sh b/ts-to-mkv.sh index 8659e5d..536c047 100644 --- a/ts-to-mkv.sh +++ b/ts-to-mkv.sh @@ -35,7 +35,7 @@ vercomp () { ffmpegcheck(){ ffmpegversion=$("$FFMPEG" -version | head -n1 | awk '{print $3}') - vercomp "$ffmpegversion" "4" + vercomp "$ffmpegversion" "4" } ##/functions ## @@ -63,15 +63,15 @@ echo "[info] $0 -- v$version" while getopts d:p:fnhkq OPT; do case "$OPT" in d) - if [[ -e "$OPTARG" ]]; then - FFMPEG="$OPTARG" - echo "[debug] custom daemon: $OPTARG" - else - echo "[debug] no custom daemon; using $FFMPEG" - fi ;; - f) - force="-y" - echo "[debug] overwriting existing files " ;; + if [[ -e "$OPTARG" ]]; then + FFMPEG="$OPTARG" + echo "[debug] custom daemon: $OPTARG" + else + echo "[debug] no custom daemon; using $FFMPEG" + fi ;; + f) + force="-y" + echo "[debug] overwriting existing files " ;; h) echo "[help] -d, path to custom ffmpeg (default: $FFMPEG)" echo "[help] -f, force overwriting existing files" @@ -79,23 +79,23 @@ while getopts d:p:fnhkq OPT; do echo "[help] -k, keep the original ts file" echo "[help] -q, disable output from ffmpeg (default: info)" echo "[help] -p, custom path to scan recursively (default: $WORKPATH)" - exit 0;; + exit 0 ;; k) echo "[debug] keeping the original file" - keepsource="1";; - n) - force="-n" - echo "[debug] not overwriting existing files " ;; + keepsource="1" ;; + n) + force="-n" + echo "[debug] not overwriting existing files " ;; p) - if [[ -d "$OPTARG" ]]; then - WORKPATH="$OPTARG" - echo "[debug] custom pathing: $OPTARG" - else - echo "[debug] no custom pathing; using $WORKPATH" - fi ;; - q) - loglevel="quiet" - echo "[debug] disabling ffmpeg output" ;; + if [[ -d "$OPTARG" ]]; then + WORKPATH="$OPTARG" + echo "[debug] custom pathing: $OPTARG" + else + echo "[debug] no custom pathing; using $WORKPATH" + fi ;; + q) + loglevel="quiet" + echo "[debug] disabling ffmpeg output" ;; esac done @@ -103,8 +103,8 @@ shift $((OPTIND-1)) echo "[info] finding files" filelist="$(find "$WORKPATH" -name "*.ts")" if [[ "$filelist" ]]; then - for i in $filelist; - do + for i in $filelist; + do echo "[info] working on $i" INFILE="$i" echo "[debug] Infile: $INFILE" @@ -113,16 +113,16 @@ if [[ "$filelist" ]]; then sleep 2 INFILE2="${INFILE//\'/\'\\\\\\\'\'}" "$FFMPEG" \ - -i "${INFILE}" \ - -f lavfi -i movie="'${INFILE2}'[out+subcc]" \ - -map 0 -map 1:s \ - -codec:v libx264 \ - -codec:a copy \ - -codec:s srt \ - -metadata:s:s:0 language=eng \ - $force \ - -loglevel "$loglevel" \ - "${OUTFILE}" + -i "${INFILE}" \ + -f lavfi -i movie="'${INFILE2}'[out+subcc]" \ + -map 0 -map 1:s \ + -codec:v libx264 \ + -codec:a copy \ + -codec:s srt \ + -metadata:s:s:0 language=eng \ + $force \ + -loglevel "$loglevel" \ + "${OUTFILE}" exitcode="$?" if [[ $exitcode -eq 0 ]]; then @@ -134,11 +134,11 @@ if [[ "$filelist" ]]; then echo "[info] retaining original file" fi else - echo "[error] $INFILE is corrupted, abandoning..." + echo "[error] $INFILE is corrupted, abandoning..." fi - done + done else -echo "[info] no files found." + echo "[info] no files found." fi IFS=$SAVEIFS \ No newline at end of file