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

[coil-video] Support MediaDataSource implementations #1790

Closed
lukaspieper opened this issue Jun 9, 2023 · 1 comment · Fixed by #1795
Closed

[coil-video] Support MediaDataSource implementations #1790

lukaspieper opened this issue Jun 9, 2023 · 1 comment · Fixed by #1795
Labels
enhancement New feature or request

Comments

@lukaspieper
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently Coil-Video only supports a small range of inputs (see MediaMetadataRetriever.setDataSource(...) and if I understand it correctly with a fallback that writes a whole file to disk that is way to slow for large files like videos. In my case the files are encrypted, therefor they cannot directly be used by coil.

Describe the solution you'd like
I have a MediaDataSource implementation that handles the decryption on the fly. However, I haven’t found a way to pass it down to coil without extending Coil's image pipeline by adding a class that is similar to VideoFrameDecoder but forwards the MediaDataSource to the MediaMetadataRetriever.

I just barely checked the code base, so there could be better solutions. The VideoFrameDecoder would need to recognize MediaDataSource to apply them directly. I think this could be done by adding an ImageSource that accepts MediaDataSource as parameter.

I have seen issue #25 so this new API would only be available on > API 23.

Additional context
While I was able to implement this myself by mostly copying VideoFrameDecoder, I think it would be nice to see support upstream.

@lukaspieper lukaspieper added the enhancement New feature or request label Jun 9, 2023
@colinrtwhite
Copy link
Member

Hmm this might be slightly tough to implement. An ImageSource implementation needs to be able to return a Source so it can be ready by any fetcher. A MediaDataSource could be wrapped as a Source, however when read by VideoFrameDecoder it would create a temporary file on disk, which we want to avoid. Additionally, we can't add this to the main artifact - it would need to exist as part of coil-video.

I think the best way to implement this is probably create a custom MediaDataSourceFetcher that wraps MediaDataSource as a Source-backed ImageSource and attaches a MediaSourceMetadata object, which can then be read by VideoFrameDecoder. Open to a PR that adds this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants