我正在开发的应用程序允许用户创建像Facebook这样的带有文本、图像和视频的社交帖子。我正在做PWA的一部分,我遇到了这个问题。为了从存储中选择视频,我需要创建要在UI中显示的视频的缩略图。
我可以选择Uint8List
格式的视频,因为它在所有平台上都受支持,但我无法从中获得缩略图。我尝试了很多库,但都使用File
作为输入。
有没有办法让我把这件事做完?
我正在使用以下代码来获取视频文件的Uint8List ...
使用的库:file_picker_cross
final filePicker = FilePickerCross(type: FileTypeCross.video);
await filePicker.pick();
final imageBytes = filePicker.toUint8List();
// TODO: get video thumbnail from [imageBytes]
发布于 2021-03-05 16:47:46
您可以在flutter项目中使用video_thumbnail 0.2.5+1插件
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,
);
);
https://stackoverflow.com/questions/62126032
复制相似问题