|
|
@ -12,42 +12,65 @@ |
|
|
|
FFBIN="/usr/bin/" #if unusual install or a specific version |
|
|
|
HostName="localhost" #if localhost then will do locally (removes ssh/scp cmds) |
|
|
|
hostFile="/tmp/transcode/list.txt" |
|
|
|
tmpDIR="$PWD/tmpTranscode" |
|
|
|
workDIR="$PWD/transcode" |
|
|
|
tmpDIR="$PWD/tmpTranscode" |
|
|
|
|
|
|
|
#DEFINE FUNCTIONS |
|
|
|
function encode { |
|
|
|
local tmpFL=$1 |
|
|
|
local inFL=$1 |
|
|
|
local outFL=$2 |
|
|
|
$FFBIN/ffmpeg -hide_banner -loglevel error -stats -re -i "$tmpFL" -map 0 \ |
|
|
|
-map_metadata 0 -c copy \ |
|
|
|
-c:v libsvtav1 -crf 28 -g 240 -preset 6 -svtav1-params \ |
|
|
|
"enable-overlays=1:\ |
|
|
|
tune=0" \ |
|
|
|
-use_wallclock_as_timestamps 1 \ |
|
|
|
-map_chapters 0 -max_muxing_queue_size 9999 -y "$outFL" |
|
|
|
local burn=$3 |
|
|
|
|
|
|
|
if [ $burn -gt -1 ] |
|
|
|
then |
|
|
|
inline="-i "$tmpDIR/dummy.mkv"" |
|
|
|
vidline="-map 1:v:0" |
|
|
|
subline="-map -0:s:$burn" |
|
|
|
else |
|
|
|
unset inline |
|
|
|
vidline="-map 0:v:0" |
|
|
|
unset subline |
|
|
|
fi |
|
|
|
|
|
|
|
$FFBIN/ffmpeg -hide_banner -loglevel error -stats \ |
|
|
|
-i "$inFL" $inline \ |
|
|
|
-map_metadata 0 \ |
|
|
|
$vidline \ |
|
|
|
-c:v libsvtav1 -crf 28 -preset 4 -pix_fmt yuv420p10le \ |
|
|
|
-svtav1-params \ |
|
|
|
"enable-overlays=1:\ |
|
|
|
tune=0:\ |
|
|
|
keyint=7s" \ |
|
|
|
-map 0:a? -acodec aac \ |
|
|
|
-map 0:s? -scodec copy $subline \ |
|
|
|
-use_wallclock_as_timestamps 1 -max_interleave_delta 0 \ |
|
|
|
-map_chapters 0 -max_muxing_queue_size 9999 -y "$outFL" |
|
|
|
} |
|
|
|
|
|
|
|
function burnSubs { |
|
|
|
local inFL=$1 |
|
|
|
local tmpFL=$2 |
|
|
|
local outFL=$3 |
|
|
|
local track=$4 |
|
|
|
local outFL=$2 |
|
|
|
local track=$3 |
|
|
|
|
|
|
|
#EVIDTNELY NECESSARY SO THAT FILES AREN'T 198+ HRS IN LEN. AT THE END |
|
|
|
local DURATION=$( $FFBIN/ffprobe -loglevel error -show_entries format=duration \ |
|
|
|
-of default=noprint_wrappers=1:nokey=1 "$inFL" ) |
|
|
|
|
|
|
|
$FFBIN/ffmpeg -hide_banner -loglevel error -stats -i "$inFL" \ |
|
|
|
-filter_complex "[0:v][0:s:$track]overlay[v]" -map "[v]" \ |
|
|
|
-filter_complex_threads 1 \ |
|
|
|
-map 0:a -c:a copy -map 0:s -map -0:s:$track -c:s copy \ |
|
|
|
-map_metadata 0 -map_chapters 0 -max_muxing_queue_size 4096 \ |
|
|
|
-t $DURATION -threads 1 -y "$tmpFL" |
|
|
|
|
|
|
|
rm "$inFL" #SAVE SPACE |
|
|
|
$FFBIN/ffmpeg -hide_banner -stats -i "$inFL" \ |
|
|
|
-map_metadata -1 \ |
|
|
|
-filter_complex "[0:v][0:s:$track]overlay[v]" -map "[v]" \ |
|
|
|
-filter_complex_threads 1 \ |
|
|
|
-an -sn \ |
|
|
|
-max_muxing_queue_size 4096 \ |
|
|
|
-t $DURATION -y "$tmpDIR/dummy.mkv" |
|
|
|
|
|
|
|
encode "$tmpFL" "$outFL" |
|
|
|
if ! [ $? -eq 0 ] |
|
|
|
then |
|
|
|
echo "Sub Burn Failed" |
|
|
|
return 10 |
|
|
|
else |
|
|
|
encode "$inFL" "$outFL" $track |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
#MAIN FUNCTION BEGINS |
|
|
@ -137,7 +160,7 @@ do |
|
|
|
then |
|
|
|
#ONLY ONE ENG. SUB TRACK |
|
|
|
echo "ONE ENG. SUB TRACK" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 |
|
|
|
else |
|
|
|
#TEST SUBTITLE TYPE; IF NOT PGS SKIP IT; FEEL FREE TO FILL IN |
|
|
|
if grep -qi "pgs" <<< $( $FFBIN/ffprobe -loglevel error -select_streams s \ |
|
|
@ -190,10 +213,10 @@ do |
|
|
|
if [ $( echo "($currFrames / $maxFrames) < 0.25"|bc -l ) -gt 0 ] |
|
|
|
then |
|
|
|
echo "BURNING STREAM $SUBTITLEINDEX (STREAM $minINDEX) from $fileNAME" |
|
|
|
burnSubs "$tmpDIR/$fileNAME" "$tmpDIR/TMP$fileNAME" "$workDIR/$fileNAME" $SUBTITLEINDEX |
|
|
|
burnSubs "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" $SUBTITLEINDEX |
|
|
|
else |
|
|
|
echo "MIN. SUB TRACK ($SUBTITLEINDEX [$minINDEX])) DUR. > 25% FILM, NOT BURNING" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
@ -203,12 +226,12 @@ do |
|
|
|
#I'm actually kinda missing a good example; I'm sure they're in there |
|
|
|
#but I don't know which ones they are lol; lmk if you know one. |
|
|
|
echo "NOT A PGS SUBTITLE TYPE; PASSING ALL THROUGH, FUTURE DEV." |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
else |
|
|
|
#ONE OR FEWER SUB TRACKS |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ $? != 0 ] || [ $( stat -c%s "$workDIR/$fileNAME" ) -eq 0 ] |
|
|
@ -261,11 +284,11 @@ do |
|
|
|
if ls "$tmpDIR"/"$fileNAME" |
|
|
|
then |
|
|
|
rm "$tmpDIR"/"$fileNAME" |
|
|
|
elif ls "$tmpDIR"/"TMP$fileNAME" |
|
|
|
elif ls "$tmpDIR"/"dummy.mkv" |
|
|
|
then |
|
|
|
rm "$tmpDIR"/"TMP$fileNAME" |
|
|
|
rm "$tmpDIR"/"dummy.mkv" |
|
|
|
else |
|
|
|
echo "Already removed $tmpDIR/$fileNAME?" |
|
|
|
echo "Already removed temp. file(s)" |
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|