More AV Changes (#2)

* Ensure pass variable is empty.

* Check status of first pass manually. Default to only doing 1 pass while researching exit status 187 on long videos.

* Try and make the final du more accurate.

* Enhance usability of basic-process.
This commit is contained in:
Hyperling 2024-05-16 10:02:53 -07:00 committed by GitHub
parent 6a9f363771
commit 3bb4e2794b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,6 +111,10 @@ function process-video {
fi fi
size="-filter:v scale=-1:$size" size="-filter:v scale=-1:$size"
if [[ -z $passes ]]; then
passes=1
fi
pass=""
if [[ $passes != 1 ]]; then if [[ $passes != 1 ]]; then
passes=2 passes=2
pass="-pass 2" pass="-pass 2"
@ -125,11 +129,15 @@ function process-video {
-i "$file" $size $video $audio \ -i "$file" $size $video $audio \
-filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \ -filter:a "dynaudnorm=f=33:g=65:p=0.66:m=33.3" \
-vcodec libx264 -movflags +faststart \ -vcodec libx264 -movflags +faststart \
-pass 1 -f mp4 /dev/null -y && -pass 1 -f mp4 /dev/null -y
set +x && status=$?
echo "`date` - Done with the first pass." || set +x
echo "`date` - Done with the first pass."
if [[ $status != 0 ]]; then
echo "Received unsuccessful status, exiting."
return 1 return 1
fi fi
fi
set -x && set -x &&
ffmpeg -nostdin -hide_banner -loglevel quiet \ ffmpeg -nostdin -hide_banner -loglevel quiet \
@ -146,7 +154,8 @@ function process-video {
fi fi
sync sync
sleep 5 sleep 10
sync
if [[ -s $newfile ]]; then if [[ -s $newfile ]]; then
echo "`date` - Getting file sizes." echo "`date` - Getting file sizes."
du -h "$file" du -h "$file"
@ -257,11 +266,31 @@ function basic-process {
echo "`date` - Finished basic-process" echo "`date` - Finished basic-process"
return 0 return 0
} }
alias v2a="basic-process" alias bp="basic-process"
alias bv="bp"
# Function to automatically append tbe Y.
function fix-audio {
basic-process "$1" Y
}
# Function to easily turn a video to audio without typing the audio name.
function convert-to-audio {
video="$1"
audio="$2"
if [[ -z "$2" || "$2" == "Y" ]]; then
audio="${1//mp4/mp3}"
fi
volume=""
if [[ ( "$2" == "Y" && -z "$3" ) || "$3" == "Y" ]]; then
$volume="Y"
fi
basic-process "$video" "$audio" $volume
}
alias v2a="convert-to-audio"
alias vta="v2a" alias vta="v2a"
alias va="v2a" alias va="v2a"
alias pa="v2a" alias pa="v2a"
alias fix-audio="basic-process"
# Go to normal storage. DISABLED, use shortcut aliases instead. # Go to normal storage. DISABLED, use shortcut aliases instead.
#cd ~/storage/shared/ #cd ~/storage/shared/