Compare commits

..

No commits in common. "9c0e598ce2e559542b6bb6f5dd27c3c0288236af" and "97a21bd75f267516d20f282a215805b8d25e071c" have entirely different histories.

2 changed files with 5 additions and 49 deletions

View file

@ -11,11 +11,11 @@ for INFILE in "$@"
do do
echo "$INFILE" echo "$INFILE"
COMMON="$OPTS --hdr --exposure=-2.5 --peak=141 --fps=60000/1001" COMMON="$OPTS --exposure=-2.5 --peak=141 --fps=60000/1001"
SPEED_SMALL="veryslow" SPEED_SMALL="veryslow"
SPEED_LARGE="medium" SPEED_LARGE="medium"
SMALL="$COMMON --size=4m --preset=$SPEED_SMALL" SMALL="$COMMON --size=4m --preset=$SPEED_SMALL --quality=0.75"
LARGE="$COMMON --size=25m --preset=$SPEED_LARGE" LARGE="$COMMON --size=25m --preset=$SPEED_LARGE"
pack-vid $SMALL "$INFILE" "${INFILE%.mp4}-small.mp4" pack-vid $SMALL "$INFILE" "${INFILE%.mp4}-small.mp4"

View file

@ -26,7 +26,6 @@ $options = [
'fps' => '60000/1001', 'fps' => '60000/1001',
'size' => $maxBytes, 'size' => $maxBytes,
'quality' => 1.0, 'quality' => 1.0,
'hdr' => false,
]; ];
while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) { while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) {
@ -52,8 +51,7 @@ if ( count ( $args ) < 2 ) {
" --preset=key set h.264 encoding preset\n" . " --preset=key set h.264 encoding preset\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" . " --quality=n fraction of base bitrate to break on (deafult 0.75)\n"
" --hdr force HDR input processing on\n"
); );
} }
[ $src, $dest ] = $args; [ $src, $dest ] = $args;
@ -99,7 +97,7 @@ function ffprobe( $path ) {
} }
function evenize( $n ) { function evenize( $n ) {
$n = round( $n ); $n = ceil( $n );
if ( $n & 1 ) { if ( $n & 1 ) {
$n++; $n++;
} }
@ -148,7 +146,7 @@ function convert( $src, $dest, $options ) {
$duration = floatval( $track->duration ); $duration = floatval( $track->duration );
$width = $track->width; $width = $track->width;
$height = $track->height; $height = $track->height;
$hdr = $track->color_primaries === 'bt2020' || $options['hdr']; $hdr = $track->color_primaries === 'bt2020';
$keyframeInt = ceil( $duration * 60 ); $keyframeInt = ceil( $duration * 60 );
$bitrate = floor( $maxBits / $duration ); $bitrate = floor( $maxBits / $duration );
@ -192,48 +190,6 @@ function convert( $src, $dest, $options ) {
} }
$aspect = $width / $height; $aspect = $width / $height;
$pixels = $width * $height;
// canonical base rate is 1 megabit at 480p
$bitrate = min( $bitrate, 4 * $base );
/*
$minWidth = 640;
$minHeight = 360;
$baseWidth = 854;
$baseHeight = 480;
$pixelsPerBit = ( $baseWidth * $baseHeight ) / $base;
$maxWidth = 1920;
$maxHeight = 1080;
$maxrate = $base * ( $maxWidth * $maxHeight ) / ( $baseWidth * $baseHeight );
$pixels = $bitrate * $pixelsPerBit;
$frameHeight = evenize( sqrt( $pixels / $aspect ) );
$frameWidth = evenize( $frameHeight * $aspect );
if ( $aspect > 16 / 9 ) {
if ( $frameWidth < $minWidth ) {
$frameWidth = $minWidth;
$frameHeight = evenize( $frameWidth / $aspect );
} elseif ( $frameWidth > $maxWidth ) {
$frameWidth = $maxWidth;
$frameHeight = evenize( $frameWidth / $aspect );
$bitrate = min( $bitrate, $maxrate );
}
} else {
if ( $frameHeight < $minHeight ) {
$frameHeight = $minHeight;
$frameWidth = evenize( $frameHeight * $aspect );
} elseif ( $frameWidth > $maxWidth ) {
$frameHeight = $maxHeight;
$frameWidth = evenize( $frameHeight * $aspect );
$bitrate = min( $bitrate, $maxrate );
}
}
*/
$wide = $aspect > ( $frameWidth / $frameHeight ); $wide = $aspect > ( $frameWidth / $frameHeight );
$crop = boolval( $options['crop'] ); $crop = boolval( $options['crop'] );
$letterbox = boolval( $options['letterbox'] ); $letterbox = boolval( $options['letterbox'] );