13

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]
Birju Vachhani
  • 6,072
  • 4
  • 21
  • 43
  • I know it does but the question is how can I get a thumbnail out of a video `Uint8List`? – Birju Vachhani Jun 01 '20 at 05:25
  • wait wait wait, you have the binary content of the whole video? like 1GB for 2 hour cinema movie? – pskink Jun 01 '20 at 05:27
  • Not like that actually. See I am trying to combine android/ios app with pwa. As `File` class comes from different packages on both platforms, I am left with `Uint8List`. So I am trying to make it work and get a thumbnail from it. This solution only seems viable to be and I haven't tried to actually load video as `Uint8List` if that's what you're asking. The app doesn't allow uploading of videos more than 15 MB I guess. – Birju Vachhani Jun 01 '20 at 05:36
  • https://pub.dev/documentation/video_thumbnail/latest/ – pskink Jun 01 '20 at 05:37
  • 1
    @pskink I came across this package but as it didn't support loading thumbnail from `Uint8List`, I didn't give it a try! Iet me do that now with File! Thanks. – Birju Vachhani Jun 01 '20 at 05:41
  • you need a `String` file path, not `Uint8List` - see https://pub.dev/documentation/file_picker/latest/file_picker/FilePicker/getFilePath.html – pskink Jun 01 '20 at 05:41
  • 1
    `file_picker` doesn't work for web... – Birju Vachhani Jun 01 '20 at 05:50
  • Unfortunately, no! – Birju Vachhani Oct 10 '22 at 20:05

1 Answers1

1

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,
);

);

vinchuli
  • 409
  • 5
  • 6