Change --hdr to control hdr output instead of tonemapping of input

Keep --hdr-input for the old forcing
This commit is contained in:
Brooke Vibber 2025-10-05 15:57:09 -07:00
commit ca2ab23a97

View file

@ -30,6 +30,7 @@ $options = [
'size' => $maxBytes,
'quality' => 1.0,
'bitrate' => 0,
'hdr-input' => false,
'hdr' => false,
'dither' => false,
'width' => false,
@ -71,7 +72,8 @@ if ( count ( $args ) < 2 ) {
" --bitrate=n target bitrate (exclusive with --size)\n" .
" --size=n target file size in bytes (exclusive with --bitrate)\n" .
" --quality=n fraction of base bitrate to break on (deafult 1.0)\n" .
" --hdr force HDR input processing on\n" .
" --hdr-input force HDR input processing on\n" .
" --hdr force HDR output on (normally SDR output)\n" .
" --dither enable dithering in 8-bit downconversion\n" .
" --width=n override frame width in pixels\n" .
" --height=n override frame height in pixels\n" .
@ -190,9 +192,10 @@ function convert( $src, $dest, $options ) {
$cropLeft = intval( $options['crop-left'] );
}
// @fixme some files are missing this? trims from qt?
//$hdr = $track->color_primaries === 'bt2020' || $options['hdr'];
//$hdrInput = $track->color_primaries === 'bt2020' || $options['hdr-input'];
// pix_fmt: "yuv420p10le"
$hdr = substr( $track->pix_fmt, -5 ) === 'p10le' || $options['hdr'];
$hdrInput = substr( $track->pix_fmt, -5 ) === 'p10le' || $options['hdr-input'];
$hdr = $hdrInput && $options['hdr'];
if ( $options['keyframe-int'] ) {
$keyframeInt = intval( $options['keyframe-int'] );
} else {
@ -335,8 +338,11 @@ function convert( $src, $dest, $options ) {
if ( $vibrance ) {
$filters[] = "vibrance=$vibrance";
}
}
} elseif ( $hdrInput ) {
$filters[] = "format=yuv420p10le";
} else {
$filters[] = "format=yuv420p";
}
if ( $crop ) {
$filters[] = "crop=w=$frameWidth:h=$frameHeight";
} elseif ( $letterbox ) {