AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.56k stars 202 forks source link

About avifs encoder #1002

Open yangpenglove opened 2 years ago

yangpenglove commented 2 years ago

Hello,

I am building a tool that can help me convert all my gif files to avifs format, but there is a question about avio.

I found decoder has avio but encoder doesn't, it is very strange and may take huge memory if there are many frames.

do you have plan to add it?

Many thanks

wantehchang commented 2 years ago

Hi yangpenglove,

The avifIO struct is only used by the decoder. It is not used by the encoder. This is why the avifEncoder struct doesn't have an avifIO * io member. You can ignore avifIO in your AVIF encoding code.

The avifIO struct does have an avifIOWriteFunc write function pointer member, which is apparently intended for the encoder. But I haven't looked into this issue, so I don't know how the write function pointer will be used by the encoder.

After passing an avifImage to avifEncoderAddImage(), you can call avifImageDestroy() immediately. However, the encoded images are still cached in memory until the avifEncoderFinish() call. This caching may consume a lot of memory (essentially the size of the output avifs file) if there are many frames, but it will be much smaller than the total size of the unencoded frames.

Have you figured out how to set avifEncoder::timescale?

yangpenglove commented 2 years ago

Hello [wantehchang,

Thanks for your feedback, I have known how to use avifEncoder::timescale.

But I still hope that libavif supports caching avifImage into a file in future, because all my gif files are converted from video with a lot of frames.

Many thanks.