This commit is contained in:
Brooke Vibber 2023-04-24 21:24:51 -07:00
parent 688827cbb8
commit 19223d8288
2 changed files with 8 additions and 10 deletions

View file

@ -4,18 +4,13 @@ for INFILE in "$@"
do
echo "$INFILE"
COMMON="--exposure=-2.5 --peak=141"
COMMON="--quality=0.75 --exposure=-2.5 --peak=141"
SPEED="slow"
#SPEED="veryfast"
SMALL="$COMMON --size=4m --preset=$SPEED"
LARGE="$COMMON --size=25m --preset=$SPEED"
LETTERBOX="--quality=0.75"
CROP="--crop"
pack-vid $SMALL $CROP "$INFILE" "${INFILE%.mp4}-crop-small.mp4"
pack-vid $SMALL $LETTERBOX "$INFILE" "${INFILE%.mp4}-letterbox-small.mp4"
pack-vid $LARGE $CROP "$INFILE" "${INFILE%.mp4}-crop-large.mp4"
pack-vid $LARGE $LETTERBOX "$INFILE" "${INFILE%.mp4}-letterbox-large.mp4"
pack-vid $SMALL "$INFILE" "${INFILE%.mp4}-small.mp4"
pack-vid $LARGE "$INFILE" "${INFILE%.mp4}-large.mp4"
done

View file

@ -17,6 +17,7 @@ $maxBytes = $maxBytes * 15 / 16; // leave some headroom
$options = [
'crop' => false,
'letterbox' => false,
'no-audio' => false,
'exposure' => '0', // stops
'peak' => '1000', // '10000' is max
@ -41,7 +42,8 @@ if ( count ( $args ) < 2 ) {
die(
"Usage: $self [options...] <srcfile.mp4> <destfile.mp4>\n" .
"Options:\n" .
" --crop crop instead of padding\n" .
" --crop crop to 16:9\n" .
" --letterbox pad to 16:9\n" .
" --no-audio strip audio\n" .
" --exposure=n adjust exposure\n" .
" --peak=n set HDR peak nits\n" .
@ -177,6 +179,7 @@ function convert( $src, $dest, $options ) {
$aspect = $width / $height;
$wide = $aspect > ( $frameWidth / $frameHeight );
$crop = boolval( $options['crop'] );
$letterbox = boolval( $options['letterbox'] );
if ( $crop ) {
if ( $wide ) {
$scaleHeight = $frameHeight;
@ -213,7 +216,7 @@ function convert( $src, $dest, $options ) {
$filters[] = "format=yuv420p";
if ( $crop ) {
$filters[] = "crop=w=$frameWidth:h=$frameHeight";
} else {
} elseif ( $letterbox ) {
$offsetX = round( ( $frameWidth - $scaleWidth) / 2 );
$offsetY = round( ( $frameHeight - $scaleHeight) / 2 );
$filters[] = "pad=w=$frameWidth:h=$frameHeight:x=$offsetX:y=$offsetY";