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

can animated encoding only be done with gifs? #1909

Open
databasedav opened this issue Apr 15, 2023 · 7 comments
Open

can animated encoding only be done with gifs? #1909

databasedav opened this issue Apr 15, 2023 · 7 comments

Comments

@databasedav
Copy link

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?

@fintelia
Copy link
Contributor

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.

@databasedav
Copy link
Author

@fintelia yes i'm interested in working on such a pr, but i'll need some guidance :)

@fintelia
Copy link
Contributor

fintelia commented May 1, 2023

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.

@databasedav
Copy link
Author

@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

@fintelia
Copy link
Contributor

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

@databasedav
Copy link
Author

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 :)

@fintelia
Copy link
Contributor

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.

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

No branches or pull requests

2 participants