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