Home > Mobile >  Access to video thumbnails, the problem of the first frame
Access to video thumbnails, the problem of the first frame

Time:09-24


MetadataRetriever retriever=new MediaMetadataRetriever ();
Try {
//according to the file path for the thumbnail
Retriever. SetDataSource (the fileInfo. GetFile_path ());
//get the first frame picture
//Bitmap Bitmap=retriever. GetFrameAtTime ();
//get 1 ms frame picture
Bitmap Bitmap=retriever. GetFrameAtTime (1000, MediaMetadataRetriever. OPTION_CLOSEST_SYNC);
If (bitmap!=null) {

The fileInfo. SetBitmap (bitmap);
LogUtils. E (bitmap. GetByteCount ()/1024 + "KB w=" + bitmap. The getWidth () + "h=" + bitmap. GetHeight ());

} else {
LogUtils. E (" (bitmap==null);
}
} the catch (IllegalArgumentException e) {
e.printStackTrace();
} the finally {
Retriever. Release ();
}
Bitmap always returns null
To switch to FFmpegMediaMetadataRetriever
Matrix matrix=new Matrix();
FFmpegMediaMetadataRetriever retriever=new FFmpegMediaMetadataRetriever ();
Try {

Retriever. SetDataSource (the fileInfo. GetFile_path ());

//Bitmap Bitmap=retriever. GetFrameAtTime ();
//get 1 ms frame picture
Bitmap Bitmap=retriever. GetFrameAtTime (1000, FFmpegMediaMetadataRetriever. OPTION_CLOSEST_SYNC);
If (bitmap!=null) {
Matrix. SetScale (0.1 0.1 f, f);
Bitmap bitmap=createBitmap (bitmap, 0, 0, bitmap. The getWidth (),
Bitmap. GetHeight (), matrix, true);
//1920 x 1080 video about 2 s left and right sides, 3840 * 2160 video was about 8 s
The fileInfo. SetBitmap (bitmap);
LogUtils. E (bitmap. GetByteCount ()/1024 + "KB w=" + bitmap. The getWidth () + "h=" + bitmap. GetHeight ());
}
} the catch (IllegalArgumentException e) {
e.printStackTrace();
} the finally {
Retriever. Release ();
}

Use Glide
Glide. With (context). The load (list) get (I)) getFile_path ()). The thumbnail (0.1 f) into (viewHolder. Iv_thumb);
1920 * 1080 can be normal, according to 3840 * 2160 can't display,
List to show the filename, the information such as the length, but by FFmpegMediaMetadataRetriever each get a bitmap update item, the effect is completely can't look straight into the
There is no other way


CodePudding user response:

From the top, there is no other solution??????

CodePudding user response:

Is the local video? Local video Glide4.0 will not display thumbnails

CodePudding user response:

refer to the second floor Write_BUG small expert replies:
is the local video? Local video Glide4.0 will not display the thumbnail method


Is the local video with when it comes to using the Glide, 1920 * 1080 can be normal display, 3840 * 2160 4 k video doesn't (work well)

CodePudding user response:

Glide loaded 4 k (3840 * 2160) when the video thumbnail tip
 W/Glide: Load failed for/storage/emulated/0/Movies/SONY. Mp4 with size x14 [25] 
The class com. Bumptech. Glide. Load. Engine. GlideException: Failed to load the resource
Cause (1 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {FileInputStream - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {FileInputStream - & gt; Bitmap - & gt; Bitmap}
Cause (2 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {ParcelFileDescriptor - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {ParcelFileDescriptor - & gt; Bitmap - & gt; Bitmap}
Cause (3 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {AssetFileDescriptor - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {AssetFileDescriptor - & gt; Bitmap - & gt; Bitmap}
W/Glide: Load failed for/storage/emulated/0/Movies/SONY. Mp4 with size x140 [250]
The class com. Bumptech. Glide. Load. Engine. GlideException: Failed to load the resource
Cause (1 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {FileInputStream - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {FileInputStream - & gt; Bitmap - & gt; Bitmap}
Cause (2 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {ParcelFileDescriptor - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {ParcelFileDescriptor - & gt; Bitmap - & gt; Bitmap}
Cause (3 of 3) : class com bumptech. Glide. The load. The engine. GlideException: Failed LoadPath {AssetFileDescriptor - & gt; Bitmap - & gt; Bitmap}, LOCAL
Cause (1 of 1) : class com bumptech. Glide. The load. The engine. GlideException: Failed DecodePath {AssetFileDescriptor - & gt; Bitmap - & gt; Bitmap}

CodePudding user response:

How to say, I met last week, my picture is saved and then immediately appear this kind of problem, because the picture is not write complete immediately to the local call display will appear, when you look at your loading video isn't that true, delay time display can solve

CodePudding user response:

reference 5 floor qq_37077845 reply:
how to say, I met last week, my picture is saved and then immediately appear this kind of problem, because the picture is not write complete immediately to the local call display will appear, when you look at your loading video isn't that true, delay time display can solve


I this is loaded directly present the local video file thumbnails, not download

CodePudding user response:

, 3840 * 2160 I also is not the whole

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related