>>1856>Wait, I just saw the script tries to encode the file multiple times until it reaches the target size.
>THIS IS INSANESo neuter the script. If you remove the bits that attempt to maximize the usage of the filesize limit, it typically produces a usable, decent encodes the first time.
Since your too stupid to figure out the core of the entire thing:
bitrate=$( ($filesize * 8192) / $time) - $audio_bitrate - 10 )
quality_decrease=2.5
source_bpp=$( ($source_bitrate / $source_area ) / $quality_decrease )
resize_area=$( $bitrate / $source_bpp )
resize_height=$( $source_height * ($resize_area / $source_area) )
if [ "$resize_height" -ge "$source_height" ]
then
resize_height=$source_height
fi
resize="-vf scale=-1:${resize_height}"
ffmpeg -y -i "$source" -c:v libvpx -threads $thread_number -auto-alt-ref 1 -slices 1 -lag-in-frames 16 -cpu-used 0 -keyint_min 0 -g 360 -qmin 4 -qmax 63 -quality good -minrate ${bitrate / 10}k -maxrate ${bitrate * 4}k -b:v ${bitrate}k ${resize} -an -pass 1 -f webm /dev/null
ffmpeg -y -i "$source" -c:v libvpx -threads $thread_number -auto-alt-ref 1 -slices 1 -lag-in-frames 16 -cpu-used 0 -keyint_min 0 -g 360 -qmin 4 -qmax 63 -quality good -minrate ${bitrate / 10}k -maxrate ${bitrate * 4}k -b:v ${bitrate}k ${resize} -codec:a libvorbis -b:a ${audio_bitrate}k -ac 2 -clev 3dB -slev -6dB -pass 2 -f webm "$output"
resize_height=$source_height
fi
resize="-vf scale=-1:${resize_height}"
ffmpeg -y -i "$source" -c:v libvpx -threads $thread_number -auto-alt-ref 1 -slices 1 -lag-in-frames 16 -cpu-used 0 -keyint_min 0 -g 360 -qmin 4 -qmax 63 -quality good -minrate ${bitrate / 10}k -maxrate ${bitrate * 4}k -b:v ${bitrate}k ${resize} -an -pass 1 -f webm /dev/null
ffmpeg -y -i "$source" -c:v libvpx -threads $thread_number -auto-alt-ref 1 -slices 1 -lag-in-frames 16 -cpu-used 0 -keyint_min 0 -g 360 -qmin 4 -qmax 63 -quality good -minrate ${bitrate / 10}k -maxrate ${bitrate * 4}k -b:v ${bitrate}k ${resize} -codec:a libvorbis -b:a ${audio_bitrate}k -ac 2 -clev 3dB -slev -6dB -pass 2 -f webm "$output"
That should handle everything first attempt.