-
Notifications
You must be signed in to change notification settings - Fork 620
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
Support AVIF (AV1 Image FIle Format) #1152
Comments
For AVIF encoding, have a look at https://github.com/kornelski/cavif-rs (https://docs.rs/ravif) It's a 100% pure Rust integration with rav1e. |
I tried using the encoder with the bindings and
I believe this refers to this statement in the specification. |
I do not support AVIF-sequence format in |
Should this be reopened? There is no decoding support yet. |
I'm not always experiencing success with encoding AVIF in https://github.com/foresterre/sic which uses the latest https://github.com/image-rs/image (at time of writing v0.23.10) using the current implementation. Or, I am not sure whether it works or not, because Firefox seems unable to decode the resulting files (Firefox 81, x64 on Ubuntu): with If I disable I've made a minimal example using the I used the Is this the above usage for the minimal example correct or did I miss something? If there is something I can do to help (further), please let me know! Hoping this is an OK place to place to ask about this 😅, I'm a bit unsure whether to post here, since I did use the image crate, however, I also experience difficulties when using your cli tool with |
@foresterre chrome opens the avif files you attached just fine. In firefox I can reproduce the errors. Maybe avif support is not ready yet in Firefox? You could try filing a Firefox bug. |
This is expected. Implementation in Firefox is still very incomplete and does not support alpha channel. I'm waiting for this to be merged: |
Note that not including the For example, checking a
|
I've just been having a play around with this, trying to add support for avif to Zola, and have to say it's looking pretty amazing so far. The work people have been putting into supporting such a new format so soon after browsers are only just wiring it in is incredibly impressive. I noticed it's not currently possible to specify the quality while encoding, with it defaulting to 100%. Is this something that's going to be implemented in the future, or are there some technical hurdles preventing it? I'm happy to have a crack at adding specifying the quality if it's not already in progress. I realize this is incredibly new, so apologies for pestering; the potential benefits for the web are so big I'm really eager to start using it. |
@BezPowell it should be easy to add a function like JpegEncoder's Not a maintainer but I think a quality param would be really helpful. |
That sounds like a really good idea. I wonder whether a good solution would then be to convert the Zola uses write_to() which this would fit well with, but I'm not sure how that would impact other api interactions. Does anyone have any objections to me having a crack at wiring this up? |
I think it should also be possible to set the encoder speed parameter. Rav1e can go from 10 fastest, 0 slowest. |
@BezPowell changing the enum would be a semver breaking change so it should wait until the next breaking update of the image crate. Not sure when it's planned. Adding a function is entirely semver compatible. |
Absolutely. Sorry, I forgot to mention that in my reply, it would of course have to wait for a breaking update. I was more thinking of doing it in two stages; adding the function first and changing the enum later if that was considered a worthwhile change. |
Perhaps a |
@BezPowell both seem to be worthwhile changes to me. |
Another solution that comes to mind for the next version could be something like this: pub enum ImageOutputFormat {
Png(PngEncoderOptions),
Jpeg(JpegEncoderOptions),
Pnm(PngEncoderOptions),
Gif(GifEncoderOptions,
Ico(IcoEncoderOptions),
Bmp(BmpEncoderOptions),
Farbfeld(FarbfeldEncoderOptions),
Tga(TgaEncoderOptions),
Avif(AvifEncoderOptions),
}
// NOTE: This already exists in the current version, but using `From`
// and having a variant in `ImageOutputFormat` for unsupported formats.
impl TryFrom<ImageFormat> for ImageOutputFormat {
type Error = UnsupportedImageOutputFormat;
fn try_from(fmt: ImageFormat) -> Result<Self, Self::Error> {
match fmt {
ImageFormat::Png => Ok(Self::Png(Default::default())),
ImageFormat::Jpeg => Ok(Self::Jpeg(Default::default())),
ImageFormat::Pnm => Ok(Self::Pnm(Default::default())),
ImageFormat::Gif => Ok(Self::Gif(Default::default())),
ImageFormat::Ico => Ok(Self::Ico(Default::default())),
ImageFormat::Bmp => Ok(Self::Bmp(Default::default())),
ImageFormat::Farbfeld => Ok(Self::Farbfeld(Default::default())),
ImageFormat::Tga => Ok(Self::Tga(Default::default())),
ImageFormat::Avif => Ok(Self::Avif(Default::default())),
f => Err(UnsupportedImageOutputFormat(f)),
}
}
} |
I really like that suggestion, it feels very intuitive. |
And, perhaps more importantly, I like the flexibility it leaves for future additions. Should reduce the need for further API changes when adding new stuff for quite a while. |
AVIF decoding support is now in master! \o/ |
Spec at https://aomediacodec.github.io/av1-avif/
Since there is already a PR for FLIF support, it probably makes sense to have at least a tracking issue for AVIF as well.
The text was updated successfully, but these errors were encountered: