Add option that caches video thumbnails to disk #2197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
As #2171 comments, Fresco loads a thumbnail from local video URI without disk cache. Every time restart app or bitmap in memory cache are evicted, then Fresco need decode thumbnail from video again and it will be slow and poor performance. So put the thumbnail bitmap into disk cache will be a good choice.
To optimize for this case, I create a
LocalVideoThumbnailProducer2
class that will return anEncodedImage
, and then it can be consumed byDiskCacheWriteProducer
andEncodedMemoryCacheProducer
. We can build a new producer sequence for this case, seeProducerSequenceFactory#getLocalVideoFileFetchSequence2()
.Of course, it is a feature that you can enable/disable it by
ImageRequestBuilder
, but I think it should be enabled by default.Test Plan
put a video file test.mp4 in sdcard and got the READ_EXTERNAL_STORAGE permission, and use following code to test.