diff --git a/README.md b/README.md index 12d6b29..db4134a 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,10 @@ if it will be contained on the same system. Comments and concerns? Leave 'em, don't know if I can address them, but there's a higher chance I'll address something that way anyway. +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). + Your best bet is St. Isidore (patron St. of computers and those that use them) diff --git a/findVideos.sh b/findVideos.sh new file mode 100644 index 0000000..b43ddbc --- /dev/null +++ b/findVideos.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +#Use ffprobe to find .mkv files with h264 encoding: + +ffBin="/usr/bin/" +parentDir=$1 +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 [[ $codec == *"264"* ]] + then + echo "$line" >>/tmp/transcode/list.txt + fi +done<<<"$( find "$parentDir" -name "*.mkv" -print )" diff --git a/transcode.sh b/transcode.sh index 3145637..999a828 100644 --- a/transcode.sh +++ b/transcode.sh @@ -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