video_thumbnail
video_thumbnail copied to clipboard
BUG - This media cannot be used
I don't know why this error is occurring and I don't know how to reproduce it because this error does not happen every time...
OS: iOS
Flutter 2.8.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision cf44000065 (2 weeks ago) • 2021-12-08 14:06:50 -0800 Engine • revision 40a99c5951 Tools • Dart 2.15.0
Flutter Doctor: No issues found!
PlatformException(IO Error, Failed to write data to file, null, null)
couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media cannot be used., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x2821eeeb0 {Error Domain=NSOSStatusErrorDomain Code=-12431 "(null)"}}
I encountered the same issue when I was trying to get a thumbnail from a video taken by camera. This seems to happen on iOS only. Here's a workaround.
- Install two packages : image_gallery_saver, photo_manager
- Save video file taken by camera into user gallery
- Find the saved video with photo_manager like code below.
Future<AssetEntity?> fetchLatestVideoAsset() async {
final albums = await PhotoManager.getAssetPathList(
onlyAll: true,
type: RequestType.video,
);
if (albums.isEmpty) return null;
final assets = await albums.first.getAssetListPaged(0, 1);
return assets.first;
}
fetchLatestVideoAsset
Thanks for the answer and this workaround. Anyway, we need this issue to be fixed...
I have a fix, though I am not sure it's the proper fix. I found that if you set the requestedTimeToleranceAfter to 100ms, then the thumbnail is properly generated. I forked the repo and made a change myself for a personal project here:
https://github.com/mjbader/video_thumbnail/commit/5971ca77cd8b588f8806b99bf80916327e8551fa
I'm gonna try and use this fix now. @mjbader are you still using your fork successfully ?
@mjbader Thank you for sharing this fix.
