From 4757720ac419cdfa101fdf0365b08f8109c764df Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 9 Apr 2023 14:52:06 -0700 Subject: [PATCH] fixes --- pack-vid | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pack-vid b/pack-vid index 6560ce2..5648646 100755 --- a/pack-vid +++ b/pack-vid @@ -187,7 +187,7 @@ function convert( $src, $dest, $options ) { } $exposure = floatval( $options['exposure'] ); - $peakNits = floatval( $options['peakNits'] ); + $peakNits = floatval( $options['peak'] ); $sdrNits = 80; $peak = $peakNits / $sdrNits; @@ -215,7 +215,8 @@ function convert( $src, $dest, $options ) { // $preset = 'veryslow'; // annoying at higher resolutions $preset = 'slow'; - $passlog = tempnam( '.', 'pack-vid-passlog' ); + $tempPrefix = 'pack-vid-passlog' . rand(0,1 << 31); + $passlog = tempnam( '.', $tempPrefix ); run( 'ffmpeg', array_merge( [ '-i', $src, @@ -248,4 +249,16 @@ function convert( $src, $dest, $options ) { '-y', $dest ] ) ); + + $len = strlen( $tempPrefix ); + if ( $len > 0 ) { + $dir = dir( './' ); + for ( $entry = $dir->read(); $entry !== false; $entry = $dir->read() ) { + if ( substr( $entry, 0, $len ) === $tempPrefix ) { + print "...deleting temp file: $entry\n"; + unlink( $entry ); + } + } + $dir->close(); + } }