handle narrower than 16:9 input
This commit is contained in:
parent
bed9ce149b
commit
bb2af76233
1 changed files with 22 additions and 8 deletions
30
pack-vid
30
pack-vid
|
@ -122,12 +122,25 @@ function convert( $src, $dest, $options ) {
|
|||
$frameHeight = 1080;
|
||||
}
|
||||
|
||||
if ( $options['letterbox'] ) {
|
||||
$scaleWidth = $frameWidth;
|
||||
$scaleHeight = evenize( $height * $frameWidth / $width );
|
||||
$aspect = $width / $height;
|
||||
$wide = $aspect > ( $frameWidth / $frameHeight );
|
||||
$pad = boolval( $options['letterbox'] );
|
||||
if ( $pad ) {
|
||||
if ( $wide ) {
|
||||
$scaleWidth = $frameWidth;
|
||||
$scaleHeight = evenize( $frameWidth / $aspect );
|
||||
} else {
|
||||
$scaleHeight = $frameHeight;
|
||||
$scaleWidth = evenize( $frameHeight * $aspect );
|
||||
}
|
||||
} else {
|
||||
$scaleHeight = $frameHeight;
|
||||
$scaleWidth = evenize( $width * $frameHeight / $height );
|
||||
if ( $wide ) {
|
||||
$scaleHeight = $frameHeight;
|
||||
$scaleWidth = evenize( $frameHeight * $aspect );
|
||||
} else {
|
||||
$scaleWidth = $frameWidth;
|
||||
$scaleHeight = evenize( $frameWidth / $aspect );
|
||||
}
|
||||
}
|
||||
|
||||
$peakNits = 2000;
|
||||
|
@ -142,10 +155,11 @@ function convert( $src, $dest, $options ) {
|
|||
}
|
||||
$filters[] = "format=yuv420p";
|
||||
if ( $options['letterbox'] ) {
|
||||
$offset = round( ( $frameHeight - $scaleHeight) / 2 );
|
||||
$filters[] = "pad=h=$frameHeight:y=$offset";
|
||||
$offsetX = round( ( $frameWidth - $scaleWidth) / 2 );
|
||||
$offsetY = round( ( $frameHeight - $scaleHeight) / 2 );
|
||||
$filters[] = "pad=w=$frameWidth:h=$frameHeight:x=$offsetX:y=$offsetY";
|
||||
} else {
|
||||
$filters[] = "crop=w=$frameWidth";
|
||||
$filters[] = "crop=w=$frameWidth:h=$frameHeight";
|
||||
}
|
||||
$vf = implode( ',', $filters );
|
||||
|
||||
|
|
Loading…
Reference in a new issue