Compare commits

...

10 Commits

Author SHA1 Message Date
use
c36915d6bc updated cleaning checks 2024-01-27 19:53:48 -08:00
use
aeffd00a00 findVideos.sh now renames files with double spaces and alters the corresponding .nfo file when necessary 2024-01-27 14:51:07 -08:00
rbeck4
9366367c38 Audio codec to eac3, copy over data and attachements when applicable (for non-pgs sub types) 2023-11-27 03:39:46 -08:00
rbeck4
f2ecfc6809 Updated preset, keyframe error on arch builds? 2023-11-25 02:05:56 -08:00
rbeck4
23edf1a119 Update readme for av1 2023-11-24 16:48:48 -08:00
rbeck4
eb7c73d5f5 Update readme for av1 2023-11-24 16:48:25 -08:00
rbeck4
15c1454245 Updated for av1 encoding 2023-11-24 16:46:41 -08:00
rbeck4
7dfbf3014b Added .gitignore 2023-11-22 03:00:09 -08:00
use
11adb1de87 Update to av1 2023-11-20 00:20:40 -08:00
use
fe5564fbc2 Forgot to have the prefix infront of a command, fixed 2023-04-14 13:38:52 -07:00
4 changed files with 84 additions and 34 deletions

3
.gitignore vendored Normal file
View File

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

View File

@@ -1,11 +1,11 @@
V3
V4
USAGE:
`bash transcode.sh [num. transcodes]`
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`
) 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
subtitle files are specified. You can either run until all files are processed
(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`
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)

View File

@@ -4,12 +4,31 @@
ffBin="/usr/bin/"
parentDir=$1
destDir="/tmp/transcode/"
mkdir -p "$destDir"
while read -r line;
do
codec="$( $ffBin/ffprobe -loglevel error -select_streams v:0 -show_entries \
stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$line" )"
if [ $? -eq 0 ]
then
if [[ $codec == *"264"* ]]
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
done<<<"$( find "$parentDir" -name "*.mkv" -print )"

View File

@@ -9,42 +9,70 @@
#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
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 libx265 -preset slow -x265-params crf=23 \
-use_wallclock_as_timestamps 1 \
-map_chapters 0 -max_muxing_queue_size 9999 "$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 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 {
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=$( 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" )
$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 \
-t $DURATION "$tmpFL"
$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"
rm "$inFL" #SAVE SPACE
encode "$tmpFL" "$outFL"
if ! [ $? -eq 0 ]
then
echo "Sub Burn Failed"
return 10
else
encode "$inFL" "$outFL" $track
fi
}
#MAIN FUNCTION BEGINS
@@ -134,7 +162,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 \
@@ -187,10 +215,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
@@ -200,12 +228,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 ]
@@ -249,20 +277,20 @@ do
fi
#REMOVE THE TEMP FILE (if necessary)
if ls "$workDIR"/"$fileNAME"
if [ -f "$workDIR"/"$fileNAME" ]
then
rm "$workDIR"/"$fileNAME"
else
echo "Workdir already cleaned"
fi
if ls "$tmpDIR"/"$fileNAME"
if [ -f "$tmpDIR"/"$fileNAME" ]
then
rm "$tmpDIR"/"$fileNAME"
elif ls "$tmpDIR"/"TMP$fileNAME"
elif [ -f "$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