strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.61k stars 293 forks source link

SVT-AV1: Could not encode #971

Open sommio opened 9 months ago

sommio commented 9 months ago

Information svt-av1 1.7.0-1.1 (via ALHP) libheif 1.16.2-1.1 (via ALHP)

heif-enc --list-encoders
HEIC encoders:
- x265 = x265 HEVC encoder (3.5) [default]
AVIF encoders:
- aom = AOMedia Project AV1 Encoder Psy v3.6.0 [default]
- svt = SVT-AV1 encoder v1.7.0-dirty
- rav1e = Rav1e encoder

Reproduction

heif-enc -A -e svt image.png

Svt[info]: -------------------------------------------
Svt[info]: SVT [version]:   SVT-AV1 Encoder Lib v1.7.0-dirty
Svt[info]: SVT [build]  :   GCC 13.2.1 20230801  64 bit
Svt[info]: LIB Build date: Aug 27 2023 18:37:59
Svt[info]: -------------------------------------------
Svt[error]: Instance 1: Encoder Bit Depth shall be only 8 or 10 

Svt[warn]: If you are using tiles with the intent of increasing the decoder speed,
please also consider using --fast-decode 1, especially if the intended decoder is
running with limited multi-threading capabilities.

SvtMalloc[info]: you have no memory leak

Could not encode HEIF/AVIF file: Encoder plugin
generated an error: Unspecified: SVT-AV1 error
heif-enc -A -e svt -p input-depth=8 image.png

Error: Unsupported encoder parameter

Sample.png.zip Download

farindk commented 8 months ago

Thanks for the report. These seem to be two independent bugs or even three. f4f185b fixes passing the correct bits-per-pixel to SVT. However, it still does not work because of a crash inside SVT. I cannot see a bug on my side yet, so maybe there is really still an SVT problem.

The bpp=8 case is a bug in the PNG reader who cannot yet convert HDR to SDR. I'll still fix that.

farindk commented 8 months ago

b051d31 should implement the 8-bit output case. Note: the correct command syntax is this: heif-enc -A -e svt -b 8 image.png -p input-depth=8 is not a supported codec parameter.

sommio commented 2 months ago

Sorry farindk, it may be too late to reply, but I still can't use svtav1 params.

❯ heif-enc -A -e svt -p film-grain=18 in.png
Error: Unsupported encoder parameter
❯ heif-enc -A -e svt -p svt:film-grain=18 in.png
Error: Unsupported encoder parameter
❯ SvtAv1EncApp --help | grep film-grain
      --film-grain                 Enable film grain, default is 0 [0: off, 1-50: level of denoising for film grain]
      --film-grain-denoise         Apply denoising when film grain is ON, default is 1 [0: no denoising, film grain data is still in frame header, 1: level of denoising is set by the film-grain parameter]

In contrast, aom works fine.

heif-enc -A -e aom -p aom:enable-dnl-denoising=0 -p aom:denoise-noise-level=5 in.png

rav1e is also unable to use the encoder parameter

❯ rav1e --help | grep quantizer
      --quantizer <QUANTIZER>
      --min-quantizer <MIN_QUANTIZER>
          Minimum quantizer (0-255) to use in bitrate mode [default: 0]
❯ heif-enc -A -e rav1e -p rav1e:quantizer=10 in.png
Error: Unsupported encoder parameter
❯ heif-enc -A -e rav1e -p quantizer=10 in.png
Error: Unsupported encoder parameter
bradh commented 2 months ago

For rav1e plugin, it looks like you can use min-q but not set quantizer.

The options for svt are a bit larger, but not things like film-grain.

You could try adding those - probably not that difficult.