coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.87k stars 670 forks source link

Add support for MP4 videos #605

Open colinrtwhite opened 3 years ago

colinrtwhite commented 3 years ago

It would be great if Coil could support short MP4 videos. MP4 is now commonly used for the same use case as GIF, however it's much more efficient. Similar to GIFs, we would have to buffer the video into memory so we wouldn't be able to support large/long videos.

This would not be a replacement for ExoPlayer, which should be used to handle long videos and any advanced functionality. Any Coil MP4 support would likely only support start/stop and how many iterations to repeat.

PeterTheOne commented 2 years ago

Doesn't it already? https://coil-kt.github.io/coil/videos/

colinrtwhite commented 2 years ago

@PeterTheOne That adds support for decoding individual video frames.

atulgpt commented 1 year ago

Hi, @colinrtwhite any pointers on how to implement this? I am planning to take this issue and wanted to know upfront what I am getting into 😅

colinrtwhite commented 1 year ago

@atulgpt I think the biggest challenge will be figuring out how to get MP4s to be represented as a Drawable. Ideally we could use MediaMetadataRetriever to decode the mp4 into a custom drawable, though there are probably design limitations there.

atulgpt commented 1 year ago

Hi @colinrtwhite, Let me sync the project and see how the coil works. BTW, are there any talks or blogs that explain (or give pointers) the internal working of coli?

colinrtwhite commented 1 year ago

@sagar-viradiya Gave a great talk on some of the internals here!

fansangg commented 1 year ago

how to use imageloader in compose AsyncImage

vladmircan commented 1 year ago

@colinrtwhite Is there any timeline for this feature? I'm currently developing a project from scratch and I wanted to know if I should delay the video implementation so that I can do it using Coil.

colinrtwhite commented 1 week ago

I think the best way to implement this would be to create a Decoder.Factory that wraps FFmpeg. You can then read the ImageSource and wrap the output as a coil3.Image. I don't have plans to work on this so someone else will need to implement this. Depending on the complexity of supporting this it might make sense to have MP4 support as an external library.