diff --git a/pack-vid b/pack-vid index e6eda5d..ff578f7 100755 --- a/pack-vid +++ b/pack-vid @@ -36,8 +36,6 @@ $options = [ 'crop-height' => false, 'crop-left' => false, 'crop-top' => false, - 'tonemap' => 'hable', - 'colortemperature' => false, ]; while ( count( $args ) > 0 && substr( $args[0], 0, 2 ) == '--' ) { @@ -68,8 +66,7 @@ if ( count ( $args ) < 2 ) { " --dither enable dithering in 8-bit downconversion\n" . " --width=n override frame width in pixels\n" . " --height=n override frame height in pixels\n" . - " --keyframe-int=n set keyframe interval (default 0)\n" . - " --tonemap=mode set HDR tone mapping mode (hable, clip, etc)\n" + " --keyframe-int=n set keyframe interval (default 0)\n" ); } [ $src, $dest ] = $args; @@ -328,7 +325,6 @@ function convert( $src, $dest, $options ) { $sdrNits = 80; $peak = $peakNits / $sdrNits; $vibrance = floatval( $options['vibrance'] ); - $tonemap = $options['tonemap']; $filters = []; if ( $options['crop-width'] || $options['crop-height'] ) { @@ -340,11 +336,7 @@ function convert( $src, $dest, $options ) { if ( $exposure ) { $filters[] = "exposure=$exposure"; } - $colortemperature = $options['colortemperature']; - if ( $colortemperature ) { - $filters[] = "colortemperature=$colortemperature"; - } - $filters[] = "tonemap=$tonemap:peak=$peak:desat=0.0"; + $filters[] = "tonemap=hable:peak=$peak:desat=0.0"; if ( $options['dither'] ) { $dither = ":dither=ordered"; } else { diff --git a/prep-set b/prep-set index 3265e0d..3522348 100755 --- a/prep-set +++ b/prep-set @@ -13,10 +13,19 @@ do else echo "FILE: $INFILE" - prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.480p.sdr.thumb.jpg" - prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.1080p.sdr.h264.mp4" - prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.1080p.hdr.vp9.webm" + MAPPED="prep-set-${INFILE%.mp4}.2160p.sdr.h264.mp4" + prep-vid $OPTS "$INFILE" "$MAPPED" + + prep-vid $OPTS "$MAPPED" "${INFILE%.mp4}.360p.sdr.thumb.jpg" + prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.360p.hdr.thumb.avif" + + prep-vid $OPTS "$MAPPED" "${INFILE%.mp4}.720p.sdr.h264.mp4" + prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.720p.hdr.hevc.mp4" + + prep-vid $OPTS "$MAPPED" "${INFILE%.mp4}.1080p.sdr.av1.webm" prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.1080p.hdr.av1.webm" + + prep-vid $OPTS "$MAPPED" "${INFILE%.mp4}.2160p.sdr.av1.webm" prep-vid $OPTS "$INFILE" "${INFILE%.mp4}.2160p.hdr.av1.webm" fi done diff --git a/prep-vid b/prep-vid index aba5038..2c127bf 100755 --- a/prep-vid +++ b/prep-vid @@ -14,31 +14,20 @@ $args = $_SERVER['argv']; $self = array_shift( $args ); $profiles = [ - '480p.sdr.thumb.jpg' => [ - 'width' => 854, - 'height' => 480, + '360p.sdr.thumb.jpg' => [ + 'width' => 640, + 'height' => 360, 'codec' => 'mjpeg', + 'bitrate' => '4000k', 'still' => true, ], - '1080p.sdr.h264.mp4' => [ - 'width' => 1920, - 'height' => 1080, - 'codec' => 'libx264', - 'bitrate' => '5000k', - ], - '1080p.hdr.vp9.webm' => [ - 'width' => 1920, - 'height' => 1080, - 'codec' => 'libvpx-vp9', - 'bitrate' => '5000k', - 'hdr' => true, - ], - '1080p.hdr.av1.webm' => [ - 'width' => 1920, - 'height' => 1080, + '360p.hdr.thumb.avif' => [ + 'width' => 640, + 'height' => 360, 'codec' => 'libsvtav1', - 'bitrate' => '4000k', + 'bitrate' => '2000k', 'hdr' => true, + 'still' => true, ], '2160p.hdr.av1.webm' => [ 'width' => 3840, @@ -47,6 +36,44 @@ $profiles = [ 'bitrate' => '25000k', 'hdr' => true, ], + '2160p.sdr.av1.webm' => [ + 'width' => 3840, + 'height' => 2160, + 'codec' => 'libsvtav1', + 'bitrate' => '20000k', + ], + '2160p.sdr.h264.mp4' => [ + 'width' => 3840, + 'height' => 2160, + 'codec' => 'libx264', + 'bitrate' => '50000k', + ], + '1080p.hdr.av1.webm' => [ + 'width' => 1920, + 'height' => 1080, + 'codec' => 'libsvtav1', + 'bitrate' => '6000k', + 'hdr' => true, + ], + '1080p.sdr.av1.webm' => [ + 'width' => 1920, + 'height' => 1080, + 'codec' => 'libsvtav1', + 'bitrate' => '4800k', + ], + '720p.hdr.hevc.mp4' => [ + 'width' => 1280, + 'height' => 720, + 'codec' => 'libx265', + 'bitrate' => '4800k', + 'hdr' => true, + ], + '720p.sdr.h264.mp4' => [ + 'width' => 1280, + 'height' => 720, + 'codec' => 'libx264', + 'bitrate' => '4800k', + ], ]; $options = [ @@ -164,8 +191,7 @@ function convert( $src, $dest, $options ) { //$hdr = $track->color_primaries === 'bt2020' || $options['hdr']; // pix_fmt: "yuv420p10le" $hdr = substr( $track->pix_fmt, -5 ) === 'p10le' || $options['hdr']; - //$keyframeInt = intval( ceil( $duration * 60 ) ); - $keyframeInt = 5 * 60; + $keyframeInt = intval( ceil( $duration * 60 ) ); if (!preg_match( '/(\d+p)\.(.*?)$/', $dest, $matches ) ) { @@ -213,40 +239,17 @@ function convert( $src, $dest, $options ) { } $vf = implode( ',', $filters ); - if ( $codec === 'libvpx-vp9' ) { - $codecOptions = [ - //'-speed', 4, - '-row-mt', 1, - '-tile-columns', 2, - '-cues_to_front', 1, - ]; - } else if ( $codec === 'libsvtav1' ) { - $codecOptions = [ - //'-preset', 4, - '-svtav1-params', 'tile_columns=2', - '-cues_to_front', 1, - ]; - } else if ( $codec === 'libx264' ) { - $codecOptions = [ - '-movflags', '+faststart', - ]; - } else { - $codecOptions = []; - } - if ( $still ) { - run( 'ffmpeg', - array_merge( [ - '-i', $src, - '-vf', $vf, - '-c:v', $codec, - '-q:v', 0.95, - '-update', 1, - '-frames:v', 1, - '-an', - '-y', $dest - ], $codecOptions ) - ); + run( 'ffmpeg', [ + '-i', $src, + '-vf', $vf, + '-c:v', $codec, + '-b:v', $bitrate, + '-update', 1, + '-frames:v', 1, + '-an', + '-y', $dest + ] ); } else { $tempPrefix = 'pack-vid-passlog' . rand(0,1 << 31); $passlog = tempnam( '.', $tempPrefix ); @@ -261,7 +264,7 @@ function convert( $src, $dest, $options ) { '-pass', '1', '-passlogfile', $passlog, '-g', $keyframeInt, - ], $audio, $codecOptions, [ + ], $audio, [ '-y', '/dev/null' ] ) ); @@ -274,7 +277,8 @@ function convert( $src, $dest, $options ) { '-pass', '2', '-passlogfile', $passlog, '-g', $keyframeInt, - ], $audio, $codecOptions, [ + ], $audio, [ + '-movflags', '+faststart', '-y', $dest ] ) );