Compare commits

..

No commits in common. "c36915d6bc10ae1b825783da1dbaf5f89c8bc350" and "547698755850aad7c86976f9508a2753a332eadf" have entirely different histories.

4 changed files with 34 additions and 84 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
tmpTranscode
transcode
*.mkv

View File

@ -1,11 +1,11 @@
V4 V3
USAGE: USAGE:
`bash transcode.sh [num. transcodes]` `bash transcode.sh [num. transcodes]`
Presumes you have ffmpeg (V > 4.4), ffprobe, bc, ssh, rsync, scp. Presumes you have ffmpeg (V > 4.4), ffprobe, bc, ssh, rsync, scp.
Will take in the files listed at $hostFile (default is `/tmp/transcode/list.txt` Will take in the files listed at $hostFile (default is `/tmp/transcode/list.txt`
) and transcode them to av1. It will attempt to identify and burn-in foreign- ) and transcode them to x265. It will attempt to identify and burn-in foreign-
audio subtitle files (subtitle track < ~15% of the run time) if multiple audio subtitle files (subtitle track < ~15% of the run time) if multiple
subtitle files are specified. You can either run until all files are processed subtitle files are specified. You can either run until all files are processed
(without a following number); or for a specified number of loops. (without a following number); or for a specified number of loops.
@ -22,6 +22,6 @@ You can search for files using the `findVideos.sh` file, USAGE:
`bash findVideos.sh /top/dir/with/files` `bash findVideos.sh /top/dir/with/files`
It will use find to locate all files of type (default .mkv) and check (using It will use find to locate all files of type (default .mkv) and check (using
ffprobe) if is of type (default adds all non-av1 files to transcoding list). ffprobe) if is of type (default adds all h264 files to transcoding list).
Your best bet is St. Isidore (patron St. of computers and those that use them) Your best bet is St. Isidore (patron St. of computers and those that use them)

View File

@ -4,31 +4,12 @@
ffBin="/usr/bin/" ffBin="/usr/bin/"
parentDir=$1 parentDir=$1
destDir="/tmp/transcode/"
mkdir -p "$destDir"
while read -r line; while read -r line;
do do
codec="$( $ffBin/ffprobe -loglevel error -select_streams v:0 -show_entries \ codec="$( $ffBin/ffprobe -loglevel error -select_streams v:0 -show_entries \
stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$line" )" stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$line" )"
if [ $? -eq 0 ]
then
if [[ $codec == *"264"* ]] if [[ $codec == *"264"* ]]
then then
#Sometimes scp has issues with double spaces? echo "$line" >>/tmp/transcode/list.txt
if [[ "$line" == *" "* ]]
then
repLine="$( echo "$line" | sed "s/ //g" )"
mv "$line" "$repLine"
if [ -f "$( dirname "$line" )/$( basename "$line" .mkv ).nfo" ]
then
mv "$( dirname "$line" )/$( basename "$line" .mkv ).nfo" "$( dirname "$repLine" )/$( basename "$repLine" .mkv ).nfo"
fi
line=$repLine
unset repLine
fi
echo "$line" >>"$destDir/list.txt"
fi
else
echo "NON-ZERO for $line"
fi fi
done<<<"$( find "$parentDir" -name "*.mkv" -print )" done<<<"$( find "$parentDir" -name "*.mkv" -print )"

View File

@ -9,70 +9,42 @@
#to pray to St. Isidore... good luck if you encounter issues. #to pray to St. Isidore... good luck if you encounter issues.
#Default operations, change if necessary #Default operations, change if necessary
FFBIN="/usr/bin" #if unusual install or a specific version FFBIN="/usr/bin/" #if unusual install or a specific version
HostName="localhost" #if localhost then will do locally (removes ssh/scp cmds) HostName="localhost" #if localhost then will do locally (removes ssh/scp cmds)
hostFile="/tmp/transcode/list.txt" hostFile="/tmp/transcode/list.txt"
workDIR="$PWD/transcode"
tmpDIR="$PWD/tmpTranscode" tmpDIR="$PWD/tmpTranscode"
workDIR="$PWD/transcode"
#DEFINE FUNCTIONS #DEFINE FUNCTIONS
function encode { function encode {
local inFL=$1 local tmpFL=$1
local outFL=$2 local outFL=$2
local burn=$3 $FFBIN/ffmpeg -hide_banner -loglevel error -stats -re -i "$tmpFL" -map 0 \
-map_metadata 0 -c copy \
if [ $burn -gt -1 ] -c:v libx265 -preset slow -x265-params crf=23 \
then -use_wallclock_as_timestamps 1 \
inline="-i "$tmpDIR/dummy.mkv"" -map_chapters 0 -max_muxing_queue_size 9999 "$outFL"
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 6 -pix_fmt yuv420p10le \
-svtav1-params \
"enable-overlays=1:\
tune=0:\
keyint=10s" \
-map 0:a? -c:a eac3 \
-map 0:s? -c:s copy $subline \
-map 0:d? -c:d copy \
-map 0:t? -c:t copy \
-use_wallclock_as_timestamps 1 -max_interleave_delta 0 \
-map_chapters 0 -max_muxing_queue_size 9999 -y "$outFL"
} }
function burnSubs { function burnSubs {
local inFL=$1 local inFL=$1
local outFL=$2 local tmpFL=$2
local track=$3 local outFL=$3
local track=$4
#EVIDTNELY NECESSARY SO THAT FILES AREN'T 198+ HRS IN LEN. AT THE END #EVIDTNELY NECESSARY SO THAT FILES AREN'T 198+ HRS IN LEN. AT THE END
local DURATION=$( $FFBIN/ffprobe -loglevel error -show_entries format=duration \ local DURATION=$( ffprobe -loglevel error -show_entries format=duration \
-of default=noprint_wrappers=1:nokey=1 "$inFL" ) -of default=noprint_wrappers=1:nokey=1 "$inFL" )
$FFBIN/ffmpeg -hide_banner -stats -i "$inFL" \ $FFBIN/ffmpeg -hide_banner -loglevel error -stats -i "$inFL" \
-map_metadata -1 \ -filter_complex "[0:v][0:s:$track]overlay[v]" -map "[v]" \
-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 \
-filter_complex_threads 1 \ -map_metadata 0 -map_chapters 0 -max_muxing_queue_size 9999 \
-an -sn \ -t $DURATION "$tmpFL"
-max_muxing_queue_size 4096 \
-t $DURATION -y "$tmpDIR/dummy.mkv"
if ! [ $? -eq 0 ] rm "$inFL" #SAVE SPACE
then
echo "Sub Burn Failed" encode "$tmpFL" "$outFL"
return 10
else
encode "$inFL" "$outFL" $track
fi
} }
#MAIN FUNCTION BEGINS #MAIN FUNCTION BEGINS
@ -162,7 +134,7 @@ do
then then
#ONLY ONE ENG. SUB TRACK #ONLY ONE ENG. SUB TRACK
echo "ONE ENG. SUB TRACK" echo "ONE ENG. SUB TRACK"
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME"
else else
#TEST SUBTITLE TYPE; IF NOT PGS SKIP IT; FEEL FREE TO FILL IN #TEST SUBTITLE TYPE; IF NOT PGS SKIP IT; FEEL FREE TO FILL IN
if grep -qi "pgs" <<< $( $FFBIN/ffprobe -loglevel error -select_streams s \ if grep -qi "pgs" <<< $( $FFBIN/ffprobe -loglevel error -select_streams s \
@ -215,10 +187,10 @@ do
if [ $( echo "($currFrames / $maxFrames) < 0.25"|bc -l ) -gt 0 ] if [ $( echo "($currFrames / $maxFrames) < 0.25"|bc -l ) -gt 0 ]
then then
echo "BURNING STREAM $SUBTITLEINDEX (STREAM $minINDEX) from $fileNAME" echo "BURNING STREAM $SUBTITLEINDEX (STREAM $minINDEX) from $fileNAME"
burnSubs "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" $SUBTITLEINDEX burnSubs "$tmpDIR/$fileNAME" "$tmpDIR/TMP$fileNAME" "$workDIR/$fileNAME" $SUBTITLEINDEX
else else
echo "MIN. SUB TRACK ($SUBTITLEINDEX [$minINDEX])) DUR. > 25% FILM, NOT BURNING" echo "MIN. SUB TRACK ($SUBTITLEINDEX [$minINDEX])) DUR. > 25% FILM, NOT BURNING"
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME"
fi fi
@ -228,12 +200,12 @@ do
#I'm actually kinda missing a good example; I'm sure they're in there #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. #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." echo "NOT A PGS SUBTITLE TYPE; PASSING ALL THROUGH, FUTURE DEV."
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME"
fi fi
fi fi
else else
#ONE OR FEWER SUB TRACKS #ONE OR FEWER SUB TRACKS
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1 encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME"
fi fi
if [ $? != 0 ] || [ $( stat -c%s "$workDIR/$fileNAME" ) -eq 0 ] if [ $? != 0 ] || [ $( stat -c%s "$workDIR/$fileNAME" ) -eq 0 ]
@ -277,20 +249,20 @@ do
fi fi
#REMOVE THE TEMP FILE (if necessary) #REMOVE THE TEMP FILE (if necessary)
if [ -f "$workDIR"/"$fileNAME" ] if ls "$workDIR"/"$fileNAME"
then then
rm "$workDIR"/"$fileNAME" rm "$workDIR"/"$fileNAME"
else else
echo "Workdir already cleaned" echo "Workdir already cleaned"
fi fi
if [ -f "$tmpDIR"/"$fileNAME" ] if ls "$tmpDIR"/"$fileNAME"
then then
rm "$tmpDIR"/"$fileNAME" rm "$tmpDIR"/"$fileNAME"
elif [ -f "$tmpDIR"/"dummy.mkv" ] elif ls "$tmpDIR"/"TMP$fileNAME"
then then
rm "$tmpDIR"/"dummy.mkv" rm "$tmpDIR"/"TMP$fileNAME"
else else
echo "Already removed temp. file(s)" echo "Already removed $tmpDIR/$fileNAME?"
fi fi
else else