#!/bin/sh -- # Make executable and Run in directory containing files? # Convert all '.ts' files in directory using ffmpeg using nvidia hardware hevc(x265) encoding, maintain orginal audio # and extract subtitles/closed-caption as '.srt' to current directory. # Start looping over files, tell what we do and log any output to screen and log. for MPEG in *.ts; do echo "Starting ${MPEG}" ffmpeg -i "${MPEG}" -c:a copy -c:v hevc_nvenc -b:v 3000k -minrate 1000k -maxrate 8000k -level 4.1 -tag:v hvc1 -preset slow -rc-lookahead 32 -movflags faststart "${MPEG%.ts}.mp4" 2>&1 | tee -a "conversion.log" # If ffmpeg exited OK, then say it and move the original to the backup directory. if [ $? -eq 0 ]; then # Extract subtitles ccextractor "${MPEG}" echo "Completed ${MPEG%.ts}.mp4" else # If ffmpeg failed, then say so and exit loop. echo "FAILED converting ${MPEG}, exiting."; exit 1; fi done # End of file loop # Exit. exit 0