diff --git a/pack-vid b/pack-vid index 17ca5d6..ce71466 100755 --- a/pack-vid +++ b/pack-vid @@ -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',