Open databasedav opened 1 year ago
No, I think you're right that GIFs are the only animated format we currently support on the encoding side. The focus of this crate is on images rather than videos, but reach out if you'd be interested in working on a PR to add animated PNG/webp/etc.
@fintelia yes i'm interested in working on such a pr, but i'll need some guidance :)
Which format are you hoping to add? The first step would be to look at how the encoding for that format is currently implemented, and see what pieces are already in place for handling animation.
@fintelia i think png would be a good start since i want it to run on wasm and can't find any pure rust encoders for webp or avif (yet), there's pure rust apng encoding support in https://github.com/poccariswet/apng, which can be used as inspiration
In fact, given that the PNG crate already implements a set_animated method, I think a lot of the pieces may already be in place
hi @fintelia just wanted to follow up on this, can u please provide some high level guidance on what needs to be done here? this is likely the lowest level thing i've ever done, but i think i can get it done with your help :)
The first step would probably be writing a standalone app using the png
crate to encode a APNG animation. I'd suggest looking through the docs.rs generated documentation and perhaps digging into the crate source code if the process
seems unclear. Roughly, it looks like you need to be create an Encoder
, call set_animated
then write_header
, use write_image_data
to write each successive frame, and then call finish
. Once you're able to generate valid animations, the next step would be porting it to the API used by this crate so that it can be merged here.
so a few of the formats (e.g. png, webp, gif) can be transformed into frames after decoding, but it looks like only the gif encoder has a convenient frames consumer method
.encode_frames
, but based on the avif encoder's use of.write_all
in the.write_image
method, does that mean i could somehow call.write_image
with data from each of the frames to encode an animated avif?