From 2f42f759b609e21170d06f415a5e63414ff3be74 Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Thu, 30 May 2019 20:22:11 -0700 Subject: [PATCH] Add unmodified from last perfect script. --- ts-to-mkv.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ts-to-mkv.sh diff --git a/ts-to-mkv.sh b/ts-to-mkv.sh new file mode 100644 index 0000000..5e5af78 --- /dev/null +++ b/ts-to-mkv.sh @@ -0,0 +1,45 @@ +#!/bin/bash +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") + +echo "[info] convert .ts to .mkv; v1 start" +echo "[info] finding files" +filelist="$(find ./ -name "*.ts")" +if [[ "$filelist" ]]; then + for i in $filelist; + do + if [[ "$i" == "./*/*.ts" ]] || [[ "$i" == "./*.ts" ]] || [[ "$i" == "./*/*/*.ts" ]]; then + echo "[exit] no files found." + exit 0 + fi + sleep 2 + echo "[info] working on $i" + INFILE="$i" + echo "[debug] Infile: $INFILE" + OUTFILE="${i//.ts/.mkv}" + echo "[debug] Outfile: $OUTFILE" + sleep 2 + + INFILE2="${INFILE//\'/\'\\\\\\\'\'}" + /data/sourcecode/ffmpeg/ffmpeg-4.1.3-amd64-static/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 \ + "${OUTFILE}" + + exitcode="$?" + if [[ $exitcode -eq 0 ]]; then + rm -v "$INFILE" + else + echo "[error] PROBLEM FOUND IN $INFILE, moving on..." + fi + done +else +echo "[info] no files found." +fi + +IFS=$SAVEIFS \ No newline at end of file