crop option
This commit is contained in:
parent
5ba048b8c8
commit
869251fb65
1 changed files with 26 additions and 1 deletions
27
pack-vid
27
pack-vid
|
@ -32,6 +32,8 @@ $options = [
|
|||
'height' => false,
|
||||
'keyframe-int' => 0,
|
||||
'vibrance' => 0,
|
||||
'crop-width' => false,
|
||||
'crop-height' => false,
|
||||
];
|
||||
|
||||
while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) {
|
||||
|
@ -157,6 +159,25 @@ function convert( $src, $dest, $options ) {
|
|||
$duration = floatval( $probe->format->duration );
|
||||
$width = $track->width;
|
||||
$height = $track->height;
|
||||
$cropLeft = 0;
|
||||
$cropTop = 0;
|
||||
|
||||
if ( $options['crop-width'] ) {
|
||||
$cropWidth = intval( $options['crop-width'] );
|
||||
$cropLeft = intval( ( $width - $cropWidth ) / 2 );
|
||||
$width = $cropWidth;
|
||||
}
|
||||
if ( $options['crop-height'] ) {
|
||||
$cropHeight = intval( $options['crop-height'] );
|
||||
$cropTop = intval( ( $height - $cropHeight ) / 2 );
|
||||
$height = $cropHeight;
|
||||
}
|
||||
if ( $options['crop-top'] ) {
|
||||
$cropTop = intval( $options['crop-top'] );
|
||||
}
|
||||
if ( $options['crop-left'] ) {
|
||||
$cropLeft = intval( $options['crop-left'] );
|
||||
}
|
||||
// @fixme some files are missing this? trims from qt?
|
||||
//$hdr = $track->color_primaries === 'bt2020' || $options['hdr'];
|
||||
// pix_fmt: "yuv420p10le"
|
||||
|
@ -303,7 +324,11 @@ function convert( $src, $dest, $options ) {
|
|||
$peak = $peakNits / $sdrNits;
|
||||
$vibrance = floatval( $options['vibrance'] );
|
||||
|
||||
$filters = [ "scale=w=$scaleWidth:h=$scaleHeight" ];
|
||||
$filters = [];
|
||||
if ( $options['crop-width'] || $options['crop-height'] ) {
|
||||
$filters[] = "crop=w=$width:x=$cropLeft:h=$height:y=$cropTop";
|
||||
}
|
||||
$filters[] = "scale=w=$scaleWidth:h=$scaleHeight";
|
||||
if ( $hdr ) {
|
||||
$filters[] = "zscale=t=linear";
|
||||
if ( $exposure ) {
|
||||
|
|
Loading…
Reference in a new issue