I want to convert the animated webp into gif and I have gif encoder+decoder and webp ecnoder and it is working fine with gifs only. I want to process the animated webp as well so I need to decode the animated webp first and get bitamps for each frames. I could not get any animated webp decoder and later found that android.graphic has Image decoder which support animated webp image but it shown example for drawable and it has start() method for animated webp.
How can I iterate through each frames to convert them into bitmap or some data type like byte[], base64, streams, etc so that i can convet that into bitmap.
File file = new File(...);
ImageDecoder.Source source = ImageDecoder.createSource(file);
Drawable drawable = ImageDecoder.decodeDrawable(source);
Here is how we can extract frames from animated webp file without using any third party library. According to Google's Container Specification for WebP image format, We need to read the image in specific way and you can do that with almost any language you like. In Java you can create InputStream of animated webp file and read data in 4 bytes in sequence. There is library android-webp-encoder for encoding webp image and written in pure java. Although you can use it for decoding the image as well. Need to modify the the library. I have modified it but not published yet. Soon I will upload it on github as I fix the bugs.
But I can explain how to modify that library to decode frames or write your own codes to decode.
PS: I will update the answer with more detailed steps and code snippets. Currently I am trying to optimise the decoder