video_thumbnail icon indicating copy to clipboard operation
video_thumbnail copied to clipboard

Couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11800

Open ritvij14 opened this issue 2 years ago • 7 comments

Uint8List? bytes = await VideoThumbnail.thumbnailData(
   video: doc["mediaUrl"],
   maxHeight: (MediaQuery.of(context).size.height * 0.25)
          .round(),
   maxWidth: (MediaQuery.of(context).size.width * 0.3).round(),
);

Trying the above code to get the thumbnail of a video stored in firebase whose URL is fetched from firestore.

Half of the times it works but rest of the times it fails, with the below error.

couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12792), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2828ac720 {Error Domain=NSOSStatusErrorDomain Code=-12792 "(null)"}}

════════ Exception caught by image resource service ════════════════════════════
The following _Exception was thrown resolving an image codec:
Exception: Invalid image data

When the exception was thrown, this was the stack
#0      _futurize (dart:ui/painting.dart:5886:5)
#1      ImageDescriptor.encoded (dart:ui/painting.dart:5741:12)
#2      instantiateImageCodecFromBuffer (dart:ui/painting.dart:2092:60)
#3      PaintingBinding.instantiateImageCodecFromBuffer
package:flutter/…/painting/binding.dart:153
#4      MemoryImage._loadAsync
package:flutter/…/painting/image_provider.dart:1090
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════

IMG_911F06E4ECB4-1

ritvij14 avatar Nov 10 '22 11:11 ritvij14

The error "Couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11800" usually indicates that there is an issue with generating a thumbnail image for a video file. This can be caused by a variety of factors, such as a corrupt or unsupported video file, an issue with the device or operating system, or a problem with the code that is generating the thumbnail.

Here are a few things you can try to fix this issue:

Check the video file: Make sure the video file is not corrupt and is in a supported format. You can try playing the video file on a different device or in a different player to see if the issue is with the file itself.

Check the device and operating system: Make sure the device and operating system you are using are compatible with the video file and the code that is generating the thumbnail. You may need to update the device or operating system to the latest version to fix any compatibility issues.

Check the code: Make sure the code that is generating the thumbnail is correct and is not causing any errors. You can use the Flutter debugger or print statements to debug the code and see where the issue is occurring.

Check for permissions: Make sure you have the necessary permissions to access the video file and generate the thumbnail. On iOS, you may need to add the NSPhotoLibraryUsageDescription key to your app's Info.plist file to request access to the photo library.

Abdullatif-Eida avatar Dec 28 '22 08:12 Abdullatif-Eida

^ If this isn't a ChatGPT response, then I don't know what is hahaah

mogsten avatar Jan 21 '23 13:01 mogsten

Hi, I have the same problem on iOS:

couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media cannot be used., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x282f15440 {Error Domain=NSOSStatusErrorDomain Code=-12431 "(null)"}}

Any updates on the problem?

tonypereiramelo avatar Mar 06 '23 11:03 tonypereiramelo

I'm using the video_thumbnail: ^0.5.3 flutter package.

Here is my code:

Future<Uint8List?> generateThumbnail(String videoUrl) async {
  try {
    final thumbnail = await VideoThumbnail.thumbnailData(video: 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_30mb.mp4');
    return thumbnail;
  } catch (e) {
    if (kDebugMode) {
      print('Error generating thumbnail: $e');
    }
    return null;
  }
}

I'm trying to load a list of thumbnails (even from the same URL), but on old IOS devices most of them are not loaded, and I'm getting the above error.

couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12792), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x283be6730 {Error Domain=NSOSStatusErrorDomain Code=-12792 "(null)"}}

Important key points:

  1. This issue occurs only for IOS devices.
  2. It happens on old devices.
  3. The file is not corrupted.
  4. When trying to load multiple thumbnails from the same URL, some are loaded while others getting the error.
  5. I tried to uninstall and rebuild the app again but nothing worked.
  6. There is no problem on Android devices.

saveKenny avatar Apr 27 '23 13:04 saveKenny

Any updates?

elsayedz avatar Dec 20 '23 11:12 elsayedz

Comment strings where imgGenerator.requestedTimeToleranceBefore and imgGenerator.requestedTimeToleranceBefore variables are set in your VideoThumbnailPlugin.m file from flutter pub sources. In my case this file is located in /Users/my_user/.pub-cache/hosted/pub.dev/video_thumbnail-/ios/Classes

mikkksa avatar Apr 30 '24 16:04 mikkksa

Hi, I have the same problem on iOS:

couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media cannot be used., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x282f15440 {Error Domain=NSOSStatusErrorDomain Code=-12431 "(null)"}}

Any updates on the problem?

Did u resolve this?

Deepali-Rai avatar Jun 28 '24 10:06 Deepali-Rai