Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Video Thumbnail from Uint8List in Flutter Web?

The app I am working on allows users to create social posts like Facebook with text, images and videos. I am working on PWA part and I came across this issue. For selecting video from storage, I need to create a thumbnail of the video to display in UI.

I was able to pick video as Uint8List as it is supported in all the platforms but I couldn't get a thumbnail from it. I tried many libraries but all are using File as an input.

Is there any way I can get this done?

I am using following code to get Uint8List of video File...

Library used: file_picker_cross

final filePicker = FilePickerCross(type: FileTypeCross.video);
await filePicker.pick();
final imageBytes = filePicker.toUint8List();
// TODO: get video thumbnail from [imageBytes]
like image 766
Birju Vachhani Avatar asked Jun 01 '20 05:06

Birju Vachhani


People also ask

What is thumbnail in flutter?

A Flutter plugin that is able to generate thumbnails for images, pdf and xlsx files. if thumbnail generation is not supported for specific mime type, then a fallback icon from FontAwesome is returned.


1 Answers

U might use video_thumbnail 0.2.5+1 plugin in your flutter project

final uint8list = await VideoThumbnail.thumbnailData(
 video: videofile.path,
 imageFormat: ImageFormat.JPEG,
 maxWidth: 128,
// specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio
quality: 25,
);

);

like image 99
vinchuli Avatar answered Oct 11 '22 03:10

vinchuli