public static Bitmap createVideoThumbnail (String filePath,
int kind)
The above method is deprecated in API
level 29.
We are required to use this now:
public static Bitmap createVideoThumbnail (File file,
Size size,
CancellationSignal signal)
My question is how can I set the Size
to be the native size of the video File
that I am creating the thumbnail from ?
I want it to be the same height/width and dimensions
.
Before, I could just use ThumbnailUtils.createVideoThumbnail(file_path, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND)
;
Use MediaMetadataRetriever class to get the size. Size will be equal to the size of video file created.
public static Size getThumbSize(String path) {
MediaMetadataRetriever dataRetriever = new MediaMetadataRetriever();
dataRetriever.setDataSource(path);
String width =
dataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
String height =
dataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
return new Size(Integer.parseInt(width), Integer.parseInt(height));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.