Fix null size variable bug with determining the default bitrate.

This commit is contained in:
Hyperling 2025-03-31 15:09:00 -07:00
parent 4bb075b747
commit e155d36ab4

View File

@ -102,25 +102,38 @@ if [[ -z "$input" ]]; then
input="."
fi
if [[ -z $size ]]; then
size="720"
fi
typeset -i size_int
size_int="$size"
# Ensure the filenames sort properly between 3 and 4 digit resolutions.
while (( ${#size} < 4 )); do
size="0$size"
done
compress_tags="$size"
size="-filter:v scale=-2:$size"
if [[ -z "$video_bitrate" ]]; then
# Based roughly on the 2.5 step iteration used for 720 and 1080.
if (( $size >= 2160 )); then
if (( size_int >= 2160 )); then
video_bitrate="30M"
elif (( $size >= 1440 )); then
elif (( size_int >= 1440 )); then
video_bitrate="12M"
elif (( $size >= 1080 )); then
elif (( size_int >= 1080 )); then
video_bitrate="5M"
elif (( $size >= 720 )); then
elif (( size_int >= 720 )); then
video_bitrate="2000k"
elif (( $size >= 480 )); then
elif (( size_int >= 480 )); then
video_bitrate="750k"
elif (( $size >= 360 )); then
elif (( size_int >= 360 )); then
video_bitrate="250k"
else
video_bitrate="100k"
fi
fi
compress_tags="$video_bitrate"
compress_tags="$compress_tags-$video_bitrate"
video_bitrate="-b:v $video_bitrate -minrate 0 -maxrate $video_bitrate -bufsize $video_bitrate"
if [[ -z "$audio_bitrate" ]]; then
@ -145,15 +158,6 @@ else
time_command="$time_command -p"
fi
if [[ -z $size ]]; then
size="720"
fi
while (( ${#size} < 4 )); do
size="0$size"
done
compress_tags="$size-$compress_tags"
size="-filter:v scale=-2:$size"
## Main ##
if [[ "$verbose" == "Y" ]]; then