Compare commits

...

7 commits

Author SHA1 Message Date
324a3fa064 whee 2025-10-05 16:32:17 -07:00
2b86f64b14 whoops 2025-10-05 16:26:49 -07:00
b58863cb1c whee 2025-10-05 16:25:16 -07:00
6b5d7328a8 whoops 2025-10-05 16:11:15 -07:00
22eacccc26 woops 2025-10-05 16:09:27 -07:00
5544d42cb4 testing hdr packset 2025-10-05 16:03:16 -07:00
ca2ab23a97 Change --hdr to control hdr output instead of tonemapping of input
Keep --hdr-input for the old forcing
2025-10-05 15:57:09 -07:00
3 changed files with 66 additions and 4 deletions

28
pack-set-hdr Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
set -e
OPTS=""
for INFILE in "$@"
do
if [[ "$1" =~ ^--.* ]]
then
echo "OPTION: $1"
OPTS="$OPTS $1"
shift
else
echo "FILE: $INFILE"
COMMON="--vcodec=libsvtav1 --hdr"
SPEED_SMALL="4"
SPEED_LARGE="4"
SMALL="$COMMON --size=4m --quality=0.5 --preset=$SPEED_SMALL"
MED="$COMMON --size=10m --quality=0.75 --preset=$SPEED_SMALL"
TEN80="$COMMON --bitrate=4000000 --width=1920 --height=1080 --preset=$SPEED_LARGE"
pack-vid $SMALL $OPTS "$INFILE" "${INFILE%.mp4}-hdr-av1-small.webm"
pack-vid $MED $OPTS "$INFILE" "${INFILE%.mp4}-hdr-av1-med.webm"
pack-vid $TEN80 $OPTS "$INFILE" "${INFILE%.mp4}-hdr-av1-1080p.webm"
fi
done

28
pack-set-vp9 Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
set -e
OPTS=""
for INFILE in "$@"
do
if [[ "$1" =~ ^--.* ]]
then
echo "OPTION: $1"
OPTS="$OPTS $1"
shift
else
echo "FILE: $INFILE"
COMMON="--vcodec=libvpx-vp9 --hdr"
SPEED_SMALL="2"
SPEED_LARGE="2"
SMALL="$COMMON --size=4m --quality=0.5 --speed=$SPEED_SMALL"
MED="$COMMON --size=10m --quality=0.75 --speed=$SPEED_SMALL"
TEN80="$COMMON --bitrate=4000000 --width=1920 --height=1080 --preset=$SPEED_LARGE"
pack-vid $SMALL $OPTS "$INFILE" "${INFILE%.mp4}-hdr-vp9-small.webm"
pack-vid $MED $OPTS "$INFILE" "${INFILE%.mp4}-hdr-vp9-med.webm"
pack-vid $TEN80 $OPTS "$INFILE" "${INFILE%.mp4}-hdr-vp9-1080p.webm"
fi
done

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 {
@ -317,6 +320,8 @@ function convert( $src, $dest, $options ) {
}
$filters[] = "scale=w=$scaleWidth:h=$scaleHeight";
if ( $hdr ) {
$filters[] = "format=yuv420p10le";
} elseif ( $hdrInput ) {
$filters[] = "zscale=t=linear:p=709:m=709";
if ( $exposure ) {
$filters[] = "exposure=$exposure";
@ -335,8 +340,9 @@ function convert( $src, $dest, $options ) {
if ( $vibrance ) {
$filters[] = "vibrance=$vibrance";
}
}
} else {
$filters[] = "format=yuv420p";
}
if ( $crop ) {
$filters[] = "crop=w=$frameWidth:h=$frameHeight";
} elseif ( $letterbox ) {