Add unmodified from last perfect script.

This commit is contained in:
Cody Cook 2019-05-30 20:22:11 -07:00
commit 2f42f759b6

45
ts-to-mkv.sh Normal file
View file

@ -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