Skip to content

Prevent HEVC encoding failure when tune is auto - #4622

Closed
lazerg wants to merge 1 commit into
lovell:mainfrom
lazerg:fix/heif-hevc-tune-auto
Closed

lazerg wants to merge 1 commit into
lovell:mainfrom
lazerg:fix/heif-hevc-tune-auto

Conversation

@lazerg

@lazerg lazerg commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

sharp always passes tune to heifsave, and the default is auto. The libheif aom plugin accepts auto, but the x265 plugin only knows psnr, ssim, grain and fastdecode, so it rejects it and every HEVC encode with default options fails with heif: Invalid parameter value (5.2006).

This leaves tune unset when it is auto. libvips then skips heif_encoder_set_parameter_string, so each encoder uses its own default. For aom that default is already auto, so AV1 output doesn't change.

I reproduced it on macOS with sharp built against a global libvips 8.18.7 and Homebrew libheif 1.23.6 (x265 4.3). heif({ compression: 'hevc' }) fails before this change and works after, via both toBuffer and toFile. AV1 output is byte-identical. I haven't added a unit test, since the prebuilt libvips has no HEVC encoder for CI to exercise. The existing unit tests all pass.

Fixes #4621

@lovell

lovell commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Thanks for taking the time to open a PR, I've taken an alternative approach to do this in JavaScript - see #4621 (comment)

@lovell lovell closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

heif() with compression 'hevc' fails with 'Invalid parameter value (5.2006)' due to default tune 'auto'

2 participants