adjust hdr peak, set pass log file

This commit is contained in:
Brooke Vibber 2023-01-30 22:54:34 -08:00
parent a80629c9ad
commit bed9ce149b
1 changed files with 8 additions and 1 deletions

View File

@ -130,10 +130,14 @@ function convert( $src, $dest, $options ) {
$scaleWidth = evenize( $width * $frameHeight / $height );
}
$peakNits = 2000;
$sdrNits = 80;
$peak = $peakNits / $sdrNits;
$filters = [ "scale=w=$scaleWidth:h=$scaleHeight" ];
if ( $hdr ) {
$filters[] = "zscale=t=linear:p=bt709";
$filters[] = "tonemap=hable:peak=8";
$filters[] = "tonemap=hable:peak=$peak";
$filters[] = "zscale=t=bt709:m=bt709:r=full";
}
$filters[] = "format=yuv420p";
@ -147,6 +151,7 @@ function convert( $src, $dest, $options ) {
$fps = 30;
$passlog = tempnam( '.', 'pack-vid-passlog' );
run( 'ffmpeg',
array_merge( [
'-i', $src,
@ -157,6 +162,7 @@ function convert( $src, $dest, $options ) {
'-b:v', $bitrate,
'-preset', 'veryslow',
'-pass', '1',
'-passlogfile', $passlog,
'-g', $keyframeInt,
], $audio, [
'-y', '/dev/null'
@ -171,6 +177,7 @@ function convert( $src, $dest, $options ) {
'-b:v', $bitrate,
'-preset', 'veryslow',
'-pass', '2',
'-passlogfile', $passlog,
'-g', $keyframeInt,
], $audio, [
'-movflags', '+faststart',