Created
January 6, 2019 08:41
-
-
Save dwin/8212afda3085ea5c30a6bd782e8c1b51 to your computer and use it in GitHub Desktop.
Revisions
-
dwin created this gist
Jan 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ #!/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