Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds AVIF support #356

Merged
merged 8 commits into from
Nov 21, 2020
Merged

Adds AVIF support #356

merged 8 commits into from
Nov 21, 2020

Conversation

LarsFronius
Copy link
Contributor

  • This adds a new type AVIF to the supported type list if libvips >= 8.9.0 is installed.
  • Calls libheif through libvips with the AV1 compression set to save AVIF images.

This should fix #353.

@LarsFronius
Copy link
Contributor Author

LarsFronius commented Oct 10, 2020

We'll perhaps need a newer libheif in the CI image if we want to keep the test for it.
We currently install 1.3.2 through upstream packages, but AVIF support only landed in 1.7.0. I'll have a look if we can compile from source.

 * This adds a new type AVIF to the supported type list if libvips >= 8.9.0
 * Calls libheif through libvips with the AV1 compression set to save AVIF images.
@LarsFronius
Copy link
Contributor Author

LarsFronius commented Oct 11, 2020

Test is slow but passing for now. Looks like the libaom en-/decoder is easiest to install for us in CI but a little on the slow side in terms of encoding performance.

There's also the option to use https://code.videolan.org/videolan/dav1d/ as decoder and https://github.com/xiph/rav1e as encoder with libheif. Both have more dependencies and would involve more changes as we'd need to compile them from source it seems, so I'd opt to stay with libaom for this use-case.

@h2non h2non self-assigned this Oct 12, 2020
@h2non
Copy link
Owner

h2non commented Oct 19, 2020

Thanks for the PR! Is this ready?

@LarsFronius
Copy link
Contributor Author

Good to go from my end! 👍

@akmittal
Copy link

Tried making it work, Getting following error

heifsave: Unsupported compression

@LarsFronius
Copy link
Contributor Author

That is the error libheif returns if it isn’t compiled with a AVIF encoder or decoder. Can you try recompiling a recent libheif from source with the rav1e or libaom encoder? I think that should make the error disappear.

I am on the go right now, but if it helps can also supply a container image that works - it works inside the travis CI tests of this PR too btw, where I install libaom and compile libheif from source.

@akmittal
Copy link

Got it to work by compiling.
I think this step also should be added in readme to install.
I see 1 issue though. .Metadata() method does not return valid info for me.

@LarsFronius
Copy link
Contributor Author

First of all: Glad to hear you got AVIF processing working!
Hmm, to be honest: I have not tested the Metadata function. I'll have a go at it sometime this week!

@akmittal
Copy link

The latest updates work and Metadata is working fine. It was somewhat of effort to make it work with libheif. I think this step should be added un readme or we should wait for libheif release with avif support to release.

@LarsFronius
Copy link
Contributor Author

Awesome - can you review the sections I added to the README? Mostly only referring to the documentation on the libheif side - no need to duplicate the information in my opinion.

@akmittal
Copy link

This looks good,

Although I have a question. https://github.com/strukturag/libheif/releases mentions that they support avif from version 1.8.0. So why we need to compile libheif for this?

@LarsFronius
Copy link
Contributor Author

LarsFronius commented Oct 28, 2020

AVIF support has been in libheif from 1.7.0 on:

  • In 1.7.0 encoding and decoding via libaom was added.
  • In 1.8.0 encoding via rav1e was added.
  • In 1.9.0 decoding via dav1d was added.

Any one of these are libraries need to be present for libheif, so that libheif can be compiled supporting them - otherwise libheif throws the "heifsave: Unsupported compression" error.

For now libvips developers have made the choice to encode/decode AVIF via libheif - there have been discussions to directly integrate with an AVIF en- or decoder, e.g. libavif, but that apparently has been dropped. libvips/libvips#1570

So for now the of libheif with one of the three aforementioned AVIF encoders/decoders needs to be made available for libvips for it to encode or decode AVIF.

@LarsFronius
Copy link
Contributor Author

Hi, is anything still needed to get this merged?

@h2non h2non merged commit 152a6b1 into h2non:master Nov 21, 2020
@h2non
Copy link
Owner

h2non commented Nov 21, 2020

Thanks for the nice work done, and apologies for the latency, OSS is not nowadays something I can spend much time on, unfortunately.

@LarsFronius
Copy link
Contributor Author

Cheers @h2non, absolutely understandable and relatable 👍
Thanks again for creating and sharing this great library!

@LarsFronius LarsFronius deleted the avif-support branch November 21, 2020 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status of AVIF support
3 participants