video_thumbnail icon indicating copy to clipboard operation
video_thumbnail copied to clipboard

BUG - This media cannot be used

Open marcobraghim opened this issue 3 years ago • 6 comments

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)"}}

marcobraghim avatar Dec 23 '21 16:12 marcobraghim

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.

  1. Install two packages : image_gallery_saver, photo_manager
  2. Save video file taken by camera into user gallery
  3. 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;
  }

APPXOTICA avatar Jan 15 '22 00:01 APPXOTICA

fetchLatestVideoAsset

Thanks for the answer and this workaround. Anyway, we need this issue to be fixed...

marcobraghim avatar Jan 17 '22 11:01 marcobraghim

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

mjbader avatar Feb 24 '22 20:02 mjbader

I'm gonna try and use this fix now. @mjbader are you still using your fork successfully ?

FilledStacks avatar May 06 '22 13:05 FilledStacks

@mjbader Thank you for sharing this fix.

justsoft avatar May 09 '22 01:05 justsoft

Screenshot 2023-01-14 at 12 19 22 AM

theappideasankit avatar Jan 13 '23 18:01 theappideasankit