Compare commits
10 Commits
5476987558
...
c36915d6bc
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c36915d6bc | ||
![]() |
aeffd00a00 | ||
![]() |
9366367c38 | ||
![]() |
f2ecfc6809 | ||
![]() |
23edf1a119 | ||
![]() |
eb7c73d5f5 | ||
![]() |
15c1454245 | ||
![]() |
7dfbf3014b | ||
![]() |
11adb1de87 | ||
![]() |
fe5564fbc2 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
tmpTranscode
|
||||||
|
transcode
|
||||||
|
*.mkv
|
@ -1,11 +1,11 @@
|
|||||||
V3
|
V4
|
||||||
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 x265. It will attempt to identify and burn-in foreign-
|
) and transcode them to av1. 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 h264 files to transcoding list).
|
ffprobe) if is of type (default adds all non-av1 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)
|
||||||
|
@ -4,12 +4,31 @@
|
|||||||
|
|
||||||
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
|
||||||
echo "$line" >>/tmp/transcode/list.txt
|
#Sometimes scp has issues with double spaces?
|
||||||
|
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 )"
|
||||||
|
86
transcode.sh
86
transcode.sh
@ -9,42 +9,70 @@
|
|||||||
#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"
|
||||||
tmpDIR="$PWD/tmpTranscode"
|
|
||||||
workDIR="$PWD/transcode"
|
workDIR="$PWD/transcode"
|
||||||
|
tmpDIR="$PWD/tmpTranscode"
|
||||||
|
|
||||||
#DEFINE FUNCTIONS
|
#DEFINE FUNCTIONS
|
||||||
function encode {
|
function encode {
|
||||||
local tmpFL=$1
|
local inFL=$1
|
||||||
local outFL=$2
|
local outFL=$2
|
||||||
$FFBIN/ffmpeg -hide_banner -loglevel error -stats -re -i "$tmpFL" -map 0 \
|
local burn=$3
|
||||||
-map_metadata 0 -c copy \
|
|
||||||
-c:v libx265 -preset slow -x265-params crf=23 \
|
if [ $burn -gt -1 ]
|
||||||
-use_wallclock_as_timestamps 1 \
|
then
|
||||||
-map_chapters 0 -max_muxing_queue_size 9999 "$outFL"
|
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 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 tmpFL=$2
|
local outFL=$2
|
||||||
local outFL=$3
|
local track=$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=$( ffprobe -loglevel error -show_entries format=duration \
|
local DURATION=$( $FFBIN/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 -loglevel error -stats -i "$inFL" \
|
$FFBIN/ffmpeg -hide_banner -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"
|
||||||
|
|
||||||
rm "$inFL" #SAVE SPACE
|
if ! [ $? -eq 0 ]
|
||||||
|
then
|
||||||
encode "$tmpFL" "$outFL"
|
echo "Sub Burn Failed"
|
||||||
|
return 10
|
||||||
|
else
|
||||||
|
encode "$inFL" "$outFL" $track
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#MAIN FUNCTION BEGINS
|
#MAIN FUNCTION BEGINS
|
||||||
@ -134,7 +162,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"
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1
|
||||||
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 \
|
||||||
@ -187,10 +215,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" "$tmpDIR/TMP$fileNAME" "$workDIR/$fileNAME" $SUBTITLEINDEX
|
burnSubs "$tmpDIR/$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"
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -200,12 +228,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"
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#ONE OR FEWER SUB TRACKS
|
#ONE OR FEWER SUB TRACKS
|
||||||
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME"
|
encode "$tmpDIR/$fileNAME" "$workDIR/$fileNAME" -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $? != 0 ] || [ $( stat -c%s "$workDIR/$fileNAME" ) -eq 0 ]
|
if [ $? != 0 ] || [ $( stat -c%s "$workDIR/$fileNAME" ) -eq 0 ]
|
||||||
@ -249,20 +277,20 @@ do
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
#REMOVE THE TEMP FILE (if necessary)
|
#REMOVE THE TEMP FILE (if necessary)
|
||||||
if ls "$workDIR"/"$fileNAME"
|
if [ -f "$workDIR"/"$fileNAME" ]
|
||||||
then
|
then
|
||||||
rm "$workDIR"/"$fileNAME"
|
rm "$workDIR"/"$fileNAME"
|
||||||
else
|
else
|
||||||
echo "Workdir already cleaned"
|
echo "Workdir already cleaned"
|
||||||
fi
|
fi
|
||||||
if ls "$tmpDIR"/"$fileNAME"
|
if [ -f "$tmpDIR"/"$fileNAME" ]
|
||||||
then
|
then
|
||||||
rm "$tmpDIR"/"$fileNAME"
|
rm "$tmpDIR"/"$fileNAME"
|
||||||
elif ls "$tmpDIR"/"TMP$fileNAME"
|
elif [ -f "$tmpDIR"/"dummy.mkv" ]
|
||||||
then
|
then
|
||||||
rm "$tmpDIR"/"TMP$fileNAME"
|
rm "$tmpDIR"/"dummy.mkv"
|
||||||
else
|
else
|
||||||
echo "Already removed $tmpDIR/$fileNAME?"
|
echo "Already removed temp. file(s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user