-
Notifications
You must be signed in to change notification settings - Fork 646
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
Add VideoFrameDecoder to support decoding video frames from any source. #689
Conversation
import coil.size.Size | ||
import kotlin.math.roundToInt | ||
|
||
internal class VideoFrameDecoderDelegate(private val context: Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is basically pulled out entirely from VideoFrameFetcher
without changes.
size: Size, | ||
options: Options | ||
): DecodeResult { | ||
val tempFile = File.createTempFile("tmp", null, context.cacheDir.apply { mkdirs() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need write permissions to do this, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! The cacheDir
is free to write to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Great work, I know this is much appreciated from those who need it.
It doesn't look like a workable solution in conjunction with streaming content urls (mpd - MPEG DASH, m3u8 - HLS), right? |
@ultraon It should work with any format supported by Android as long as the stream is not live and has completed. If you need video frames while the stream is in process I'd use ExoPlayer. |
it still didn't work with me in compose and this is my example
or this code
if there is any solution please let me know |
after a lot of pain the solution is
|
could we make a buffer of something like that as if the video is long it takes too much time to load the image ? as i think it loaded the fully video then get its thumbnail |
…e. (#689) * Add VideoFrameDecoder. * Ensure directory exists. * Updates. * Catch IOException. * Docs. * Add a test. * Update Application. * Docs.
Fixes #687.
This finally adds support for decoding video frame from any source (including the network!) with an important caveat.
VideoFrameDecoder
creates a short lived file on disk to buffer the source into. This is less performant than decoding the file in memory and it requires enough space on disk to copy the video which could be a problem for very large video files.VideoFrameFileFetcher
andVideoFrameUriFetcher
don't have this caveat which is why they're not deprecated. Long term (possibly in the next major version) we'll hopefully be able to remove this limitation onVideoFrameDecoder
and deprecate the fetchers.