bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.67k stars 6.12k forks source link

Unable to load thumbnail image from video URL #4541

Open jamesaherneplay opened 3 years ago

jamesaherneplay commented 3 years ago

Observed on Glide version 4.10 - 4.12

Observed on Android 7 samsung and Android 9 pixel with video file format profile QuickTime . Ok on Pixel 11 with file format profile Base Media / Version 2

Trying to load thumbnails images from video URLs but fails with

Implementation: val time = 1L Glide.with(context).asBitmap() .load(url) .apply(RequestOptions() .frame(time) ) .placeholder(R.color.grey) .fallback(R.drawable.image_load_failed) .into(this)

Result: The imageView displays fallback image

Error logs:

E/MediaMetadataRetrieverJNI: getFrameAtTime: videoFrame is a NULL pointer

W/Glide: Load failed for https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg with size [1038x810] class com.bumptech.glide.load.engine.GlideException: Failed to load resource There were 4 root causes: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Bitmap->Bitmap}, DATA_DISK_CACHE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Bitmap} There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details Cause (2 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Bitmap->Bitmap}, DATA_DISK_CACHE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Bitmap} Cause (3 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Bitmap->Bitmap}, DATA_DISK_CACHE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Bitmap} There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details 2021-03-31 14:58:59.899 14556-14556/com.playsportsnetwork.tourmalet W/Glide: Cause (4 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Bitmap->Bitmap}, REMOTE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Bitmap} There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details Cause (5 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Bitmap->Bitmap}, REMOTE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->Bitmap} Cause (6 of 6): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Bitmap->Bitmap}, REMOTE, https://tourmalet-beta.imgix.net/C563ECE0-5180-4A2B-86C2-88297D7809D3?w=1080&h=810&q=75&&fm=pjpg There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->Bitmap} There was 1 root cause: com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details 2021-03-31 14:58:59.899 14556-14556/com.playsportsnetwork.tourmalet I/Glide: Root cause (1 of 4) com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .MetadataRetriever. prior to this exception for details at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decodeFrame(VideoDecoder.java:222) at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decode(VideoDecoder.java:175) at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:92) at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70) at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59) at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76) at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57) at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:529) at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:493) at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:479) at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:430) at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394) at com.bumptech.glide.load.engine.DataCacheGenerator.onDataReady(DataCacheGenerator.java:94) at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:62) at com.bumptech.glide.load.engine.DataCacheGenerator.startNext(DataCacheGenerator.java:74) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:277) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

AlirezaEiji191379 commented 3 years ago

my team mate will work on this issue. @mothegoat

theablemo commented 3 years ago

Hello. If you want to get an image from your video and add it to your thumbnail, you should use the following code: (This is the Java implementation)

int microSecond = 6000000;// 6th second as an example
VideoBitmapDecoder videoBitmapDecoder = new VideoBitmapDecoder(microSecond);
FileDescriptorBitmapDecoder fileDescriptorBitmapDecoder = new FileDescriptorBitmapDecoder(videoBitmapDecoder, bitmapPool, DecodeFormat.PREFER_ARGB_8888);
Glide.with(getApplicationContext())
    .load(#YOUR_URL)
    .asBitmap()
    .override(50,50)// Example
    .videoDecoder(fileDescriptorBitmapDecoder)
    .into(#YOUR_IMAGEVIEW);

In the above code, microSecond is the time of your video you want to use as the thumbnail in micro-seconds. Just replace the video URL with _#YOURURL and your imageview holder with _#YOURIMAGEVIEW and you are good to go!

jamesaherneplay commented 3 years ago

I think FileDescriptorBitmapDecoder class is from an older version of glide and is not included in the latest version.

sanoj26692 commented 1 year ago

is there any solution i also face the same issue

Load failed for /storage/emulated/0/Download/Red.Notice.2021.720p.10bit.WEBRip.2CH.HEVC.x265-HSB.mkv
 with size [352x200]
                                                                                                    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                                                                    There were 3 root causes:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                                                                                                      Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{FileInputStream->Object->Drawable}, LOCAL
                                                                                                        Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->GifDrawable->Drawable}
                                                                                                        Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->Bitmap->BitmapDrawable}
                                                                                                        Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{FileInputStream->BitmapDrawable->Drawable}
                                                                                                      Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{ParcelFileDescriptor->Object->Drawable}, LOCAL
                                                                                                    There were 2 root causes:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                                                                                                        Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->Bitmap->BitmapDrawable}
                                                                                                    There was 1 root cause:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                                                                                                          Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
                                                                                                        Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{ParcelFileDescriptor->BitmapDrawable->Drawable}
                                                                                                    There was 1 root cause:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                                                                                                          Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
                                                                                                      Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{AssetFileDescriptor->Object->Drawable}, LOCAL
                                                                                                    There was 1 root cause:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                 W     Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{AssetFileDescriptor->Bitmap->BitmapDrawable}
                                                                                                    There was 1 root cause:
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException(MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details)
                                                                                                     call GlideException#logRootCauses(String) for more detail
                                                                                                          Cause (1 of 1): class com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
               I  Root cause (1 of 3)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decodeFrame(VideoDecoder.java:226)
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decode(VideoDecoder.java:175)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:92)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:535)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:499)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:485)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:430)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:210)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:438)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:210)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                        at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:145)
                                                                                                        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                        at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
                                                                                                        at java.lang.Thread.run(Thread.java:764)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)
                I  Root cause (2 of 3)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decodeFrame(VideoDecoder.java:226)
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decode(VideoDecoder.java:175)
                                                                                                        at com.bumptech.glide.load.resource.bitmap.BitmapDrawableDecoder.decode(BitmapDrawableDecoder.java:58)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:92)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:535)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromFetcher(DecodeJob.java:499)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromData(DecodeJob.java:485)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:430)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:210)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:438)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:394)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.onDataReadyInternal(SourceGenerator.java:210)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator$1.onDataReady(SourceGenerator.java:101)
                                                                                                        at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:145)
                                                                                                        at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:45)
                                                                                                        at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
                                                                                                        at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
                                                                                                        at java.lang.Thread.run(Thread.java:764)
                                                                                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)
              I  Root cause (3 of 3)
                                                                                                    com.bumptech.glide.load.resource.bitmap.VideoDecoder$VideoDecoderException: MediaMetadataRetriever failed to retrieve a frame without throwing, check the adb logs for .*MetadataRetriever.* prior to this exception for details
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decodeFrame(VideoDecoder.java:226)
                                                                                                        at com.bumptech.glide.load.resource.bitmap.VideoDecoder.decode(VideoDecoder.java:175)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResourceWithList(DecodePath.java:92)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decodeResource(DecodePath.java:70)
                                                                                                        at com.bumptech.glide.load.engine.DecodePath.decode(DecodePath.java:59)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.loadWithExceptionList(LoadPath.java:76)
                                                                                                        at com.bumptech.glide.load.engine.LoadPath.load(LoadPath.java:57)
                                                                                                        at com.bumptech.glide.load.engine.DecodeJob.runLoadPath(DecodeJob.java:535)
               I    at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)
tekinarslan commented 12 months ago

Hello. If you want to get an image from your video and add it to your thumbnail, you should use the following code: (This is the Java implementation)

int microSecond = 6000000;// 6th second as an example
VideoBitmapDecoder videoBitmapDecoder = new VideoBitmapDecoder(microSecond);
FileDescriptorBitmapDecoder fileDescriptorBitmapDecoder = new FileDescriptorBitmapDecoder(videoBitmapDecoder, bitmapPool, DecodeFormat.PREFER_ARGB_8888);
Glide.with(getApplicationContext())
    .load(#YOUR_URL)
    .asBitmap()
    .override(50,50)// Example
    .videoDecoder(fileDescriptorBitmapDecoder)
    .into(#YOUR_IMAGEVIEW);

In the above code, microSecond is the time of your video you want to use as the thumbnail in micro-seconds. Just replace the video URL with _#YOURURL and your imageview holder with _#YOURIMAGEVIEW and you are good to go!

Hi, I am using this code and it works good for me. I would like to try to learn memory usage of this operation. Do you know? Do Glide download whole video or stream just 1 second?

Jetpack compose

GlideImage( model = videUrl, contentDescription = "", modifier = Modifier.padding(4.dp) .fillMaxWidth().height(180.dp), contentScale = ContentScale.Crop ) { it.thumbnail( requestManager .asDrawable() .load(Uri.parse(videoUrl)) ) }