|
|
@ -9,6 +9,7 @@ |
|
|
|
#to pray to St. Isidore... good luck if you encounter issues. |
|
|
|
|
|
|
|
#Default operations, change if necessary |
|
|
|
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" |
|
|
@ -18,7 +19,7 @@ workDIR="$PWD/transcode" |
|
|
|
function encode { |
|
|
|
local tmpFL=$1 |
|
|
|
local outFL=$2 |
|
|
|
ffmpeg -hide_banner -loglevel error -stats -re -i "$tmpFL" -map 0 \ |
|
|
|
$FFBIN/ffmpeg -hide_banner -loglevel error -stats -re -i "$tmpFL" -map 0 \ |
|
|
|
-map_metadata 0 -c copy \ |
|
|
|
-c:v libx265 -preset slow -x265-params crf=23 \ |
|
|
|
-use_wallclock_as_timestamps 1 \ |
|
|
@ -35,7 +36,7 @@ function burnSubs { |
|
|
|
local DURATION=$( ffprobe -loglevel error -show_entries format=duration \ |
|
|
|
-of default=noprint_wrappers=1:nokey=1 "$inFL" ) |
|
|
|
|
|
|
|
ffmpeg -hide_banner -loglevel error -stats -i "$inFL" \ |
|
|
|
$FFBIN/ffmpeg -hide_banner -loglevel error -stats -i "$inFL" \ |
|
|
|
-filter_complex "[0:v][0:s:$track]overlay[v]" -map "[v]" \ |
|
|
|
-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 9999 \ |
|
|
@ -59,12 +60,12 @@ else |
|
|
|
iterLim="false" |
|
|
|
fi |
|
|
|
|
|
|
|
if ! command -v ffprobe &> /dev/null |
|
|
|
if ! command -v $FFBIN/ffprobe &> /dev/null |
|
|
|
then |
|
|
|
echo "Need to have ffprobe (and ffmpeg) installed" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
if ! command -v ffmpeg &> /dev/null |
|
|
|
if ! command -v $FFBIN/ffmpeg &> /dev/null |
|
|
|
then |
|
|
|
echo "Need to have ffmpeg (and ffprobe) installed" |
|
|
|
exit 1 |
|
|
@ -105,7 +106,7 @@ do |
|
|
|
unset langs |
|
|
|
|
|
|
|
#DETERMINE THE NUMBER OF ENGLISH SUBTITLES (BURNING BEHAVIOUR) |
|
|
|
for line in $( ffprobe -loglevel error -select_streams s -show_entries\ |
|
|
|
for line in $( $FFBIN/ffprobe -loglevel error -select_streams s -show_entries\ |
|
|
|
stream=index:stream_tags=language -of csv=p=0 \ |
|
|
|
"$tmpDIR"/"$fileNAME" ) |
|
|
|
do |
|
|
@ -136,7 +137,7 @@ do |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
else |
|
|
|
#TEST SUBTITLE TYPE; IF NOT PGS SKIP IT; FEEL FREE TO FILL IN |
|
|
|
if grep -qi "pgs" <<< $( ffprobe -loglevel error -select_streams s \ |
|
|
|
if grep -qi "pgs" <<< $( $FFBIN/ffprobe -loglevel error -select_streams s \ |
|
|
|
-show_entries stream=codec_name \ |
|
|
|
-of csv=p=0 "$tmpDIR"/"$fileNAME" ) |
|
|
|
then |
|
|
@ -156,7 +157,7 @@ do |
|
|
|
for index in ${streamNUMBERS[@]} |
|
|
|
do |
|
|
|
SUBINDEX=$(expr $index - ${streamNUMBERS[0]}) |
|
|
|
currFrames=$( ffprobe -loglevel error -select_streams s:$SUBINDEX \ |
|
|
|
currFrames=$( $FFBIN/ffprobe -loglevel error -select_streams s:$SUBINDEX \ |
|
|
|
-show_entries stream_tags=NUMBER_OF_FRAMES-eng -of csv=p=0 \ |
|
|
|
"$tmpDIR/$fileNAME") |
|
|
|
if [ $indexITER -lt 1 ] |
|
|
@ -180,15 +181,15 @@ do |
|
|
|
SUBTITLEINDEX=$(expr $minINDEX - ${streamNUMBERS[0]}) |
|
|
|
#TEST FRAMES IN SUB TRACK, IF < 15% MAX MOST LIKELY ISN'T FOR. AUD. |
|
|
|
#15% as LOTR dir. comm included, blows up the max number for them... |
|
|
|
currFrames=$( ffprobe -loglevel error -select_streams s:$SUBTITLEINDEX \ |
|
|
|
currFrames=$( $FFBIN/ffprobe -loglevel error -select_streams s:$SUBTITLEINDEX \ |
|
|
|
-show_entries stream_tags=NUMBER_OF_FRAMES-eng -of csv=p=0 \ |
|
|
|
"$tmpDIR/$fileNAME") |
|
|
|
if [ $( echo "($currFrames / $maxFrames) < 0.15"|bc -l ) -gt 0 ] |
|
|
|
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 |
|
|
|
else |
|
|
|
echo "MIN. SUB TRACK ($SUBTITLEINDEX [$minINDEX])) DUR. > 15% FILM, NOT BURNING" |
|
|
|
echo "MIN. SUB TRACK ($SUBTITLEINDEX [$minINDEX])) DUR. > 25% FILM, NOT BURNING" |
|
|
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" |
|
|
|
fi |
|
|
|
|
|
|
|