Make quality level adjustable
this bumps the bitrate baseline up and down set the default to 0.75 vs the original 1MB=480p baseline to allow more wiggle room
This commit is contained in:
parent
3d05a27527
commit
b4832db888
1 changed files with 7 additions and 4 deletions
11
pack-vid
11
pack-vid
|
@ -22,6 +22,7 @@ $options = [
|
||||||
'peak' => '10000',
|
'peak' => '10000',
|
||||||
'fps' => '60',
|
'fps' => '60',
|
||||||
'size' => $maxBytes,
|
'size' => $maxBytes,
|
||||||
|
'quality' => 0.75,
|
||||||
];
|
];
|
||||||
|
|
||||||
while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) {
|
while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) {
|
||||||
|
@ -44,7 +45,8 @@ if ( count ( $args ) < 2 ) {
|
||||||
" --exposure=n adjust exposure\n" .
|
" --exposure=n adjust exposure\n" .
|
||||||
" --peak=n set HDR peak nits\n" .
|
" --peak=n set HDR peak nits\n" .
|
||||||
" --fps=n frame rate limit\n" .
|
" --fps=n frame rate limit\n" .
|
||||||
" --size=n target file size in bytes (default 3.5M)\n"
|
" --size=n target file size in bytes (default 3.5M)\n" .
|
||||||
|
" --quality=n fraction of base bitrate to break on (deafult 0.75)\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
[ $src, $dest ] = $args;
|
[ $src, $dest ] = $args;
|
||||||
|
@ -148,13 +150,14 @@ function convert( $src, $dest, $options ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$mbits = 1000 * 1000;
|
$mbits = 1000 * 1000;
|
||||||
if ( $bitrate < 1 * $mbits || $height < 480 ) {
|
$base = intval( $mbits * $options['quality'] );
|
||||||
|
if ( $bitrate < 1 * $base || $height < 480 ) {
|
||||||
$frameWidth = 640;
|
$frameWidth = 640;
|
||||||
$frameHeight = 360;
|
$frameHeight = 360;
|
||||||
} elseif ( $bitrate < 2 * $mbits || $height < 720) {
|
} elseif ( $bitrate < 2 * $base || $height < 720) {
|
||||||
$frameWidth = 854;
|
$frameWidth = 854;
|
||||||
$frameHeight = 480;
|
$frameHeight = 480;
|
||||||
} elseif ( $bitrate < 4 * $mbits || $height < 1080) {
|
} elseif ( $bitrate < 4 * $base || $height < 1080) {
|
||||||
$frameWidth = 1280;
|
$frameWidth = 1280;
|
||||||
$frameHeight = 720;
|
$frameHeight = 720;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue