allow 288p, 180p, 144p output for low-bitrate videos

This commit is contained in:
Brooke Vibber 2023-06-04 11:12:31 -07:00
parent 1512776b6c
commit 830b10c318

View file

@ -171,7 +171,19 @@ function convert( $src, $dest, $options ) {
$mbits = 1000 * 1000; $mbits = 1000 * 1000;
$base = intval( $mbits * floatval( $options['quality'] ) ); $base = intval( $mbits * floatval( $options['quality'] ) );
if ( $bitrate < 1 * $base || $height < 480 ) { if ( $bitrate < 0.125 * $base || $height < 144 ) {
$frameWidth = 256;
$frameHeight = 144;
$bitrate = min( $bitrate, $base * 0.25 );
} elseif ( $bitrate < 0.25 * $base || $height < 180 ) {
$frameWidth = 320;
$frameHeight = 180;
$bitrate = min( $bitrate, $base * 0.5 );
} elseif ( $bitrate < 0.5 * $base || $height < 288 ) {
$frameWidth = 512;
$frameHeight = 288;
$bitrate = min( $bitrate, $base * 0.5 );
} elseif ( $bitrate < 1 * $base || $height < 480 ) {
$frameWidth = 640; $frameWidth = 640;
$frameHeight = 360; $frameHeight = 360;
$bitrate = min( $bitrate, $base ); $bitrate = min( $bitrate, $base );