bumptech / bumptech/glide

Load video thumbnail from raw resources or assets

Open
#1,345 9 comments 3 reactions 1 assignee Claimed by @sjudd View on GitHub
enhancement
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 3.8.0-SNAPSHOT
**Integration libraries**: N/A
**Device/Android Version**: S5 5.0.0
**Issue details / Repro steps / Use case background**:
Pradeep Kumar Reddy at [Glide — Displaying Gifs & Videos](https://futurestud.io/blog/glide-displaying-gifs-and-videos#comment-2780739306) asked:

> how to load video from resources folder instead of specifying the filePath as you showed in your example.

I put a `demo.mp4` file in both `res/raw` and `assets`; the file was created using `adb shell screenrecord /sdcard/demo.mp4`. I tried all the ways I could think of, but they all failed. The logs show that Glide is trying, but it always failing `VideoBitmapDecoder`:

``` java
mediaMetadataRetriever.setDataSource(resource.getFileDescriptor());
```

It seems that the above data source is not good enough for `MediaMetadataRetriever`, see http://stackoverflow.com/a/26151625/253468. Maybe I'm missing something or we need to special case for APK videos. Note that I even added `aaptOptions { noCompress 'mp4' }`, but it made no difference, because the failure wasn't at the point where the descriptor was opened.

**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:

``` java
Glide.with(this).load(R.raw.demo).diskCacheStrategy(NONE).into(imageView);
Glide.with(this).load("file:///android_asset/demo.mp4").diskCacheStrategy(NONE).into(imageView);
Glide.with(this).load("android.resource://" + context.getPackageName() + "/raw/demo").diskCacheStrategy(NONE).into(imageView);
```

**Stack trace / LogCat**:
of a singe load try:

``` ruby
D/skia: --- SkImageDecoder::Factory returned null
D/skia: --- SkImageDecoder::Factory returned null
E/MediaMetadataRetrieverJNI: getFrameAtTime: videoFrame is a NULL pointer
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.