my $height = $img->Get('rows');
my ($nwidth, $nheight) = scale_aspect($width, $height, $xres, $yres);
- if ($format eq 'avif') { # AVIF uses 4:2:0.
- ++$nwidth if ($nwidth % 2 == 1);
- ++$nheight if ($nheight % 2 == 1);
- }
-
my $filter = 'Lanczos';
my $quality = 87;
my $sf = "1x1";
# and Debian hasn't packaged that even in unstable as of 2021.
# So we'll need to do it the manual way. (We don't use /tmp, for security reasons.)
(my $dirname = $cachename) =~ s,/[^/]*$,,;
- my ($fh, $raw_filename) = File::Temp::tempfile('tmp.XXXXXXXX', DIR => $dirname, SUFFIX => '.yuv');
- # Write a Y4M header, so that we get the chroma siting and color space correct.
- printf $fh "YUV4MPEG2 W%d H%d F25:1 Ip A1:1 C420jpeg XYSCSS=420JPEG XCOLORRANGE=FULL\nFRAME\n", $nwidth, $nheight;
+ my ($fh, $raw_filename) = File::Temp::tempfile('tmp.XXXXXXXX', DIR => $dirname, SUFFIX => '.ycbcr');
+ # Write a Y4M header, so that we get the chroma range correct.
+ printf $fh "YUV4MPEG2 W%d H%d F25:1 Ip A1:1 C444 XYSCSS=444 XCOLORRANGE=FULL\nFRAME\n", $nwidth, $nheight;
my %parms = (
file => $fh,
filename => $raw_filename,
- 'sampling-factor' => '2x2'
+ interlace => 'Plane'
);
$cimg->write(%parms);
close($fh);
my $ivf_filename;
($fh, $ivf_filename) = File::Temp::tempfile('tmp.XXXXXXXX', DIR => $dirname, SUFFIX => '.ivf');
close($fh);
- system('aomenc', '--quiet', '--cpu-used=0', '--bit-depth=10', '--end-usage=q', '--cq-level=10', '--target-bitrate=0', '--good', '--aq-mode=1', '--matrix-coefficients=bt601', '-o', $ivf_filename, $raw_filename);
+ system('aomenc', '--quiet', '--cpu-used=0', '--bit-depth=10', '--end-usage=q', '--cq-level=13', '--target-bitrate=0', '--good', '--aq-mode=1', '--matrix-coefficients=bt601', '-o', $ivf_filename, $raw_filename);
unlink($raw_filename);
system('MP4Box', '-quiet', '-add-image', "$ivf_filename:primary", '-ab', 'avif', '-ab', 'miaf', '-new', $cachename);
unlink($ivf_filename);