Can't get multiple images from video using MPMoviePlayerController. OSStatus -12433

早过忘川 提交于 2019-12-19 17:03:34

问题


I'm trying to extract multiple images from a selected video file using MPMoviePlayerController. Below is the code I have written.

movie = [[MPMoviePlayerController alloc] initWithContentURL:[info  objectForKey:UIImagePickerControllerMediaURL]];

NSNumber *time1 = [NSNumber numberWithInt:1];
NSNumber *time2 = [NSNumber numberWithInt:3];
NSNumber *time3 = [NSNumber numberWithInt:5];

NSArray *times = [NSArray arrayWithObjects:time1,time2,time3,nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleThumbnailImageRequestFinishNotification:) name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:movie];

[movie requestThumbnailImagesAtTimes:times timeOption:MPMovieTimeOptionExact];

Here is the handler for the notification

  -(void)handleThumbnailImageRequestFinishNotification:(NSNotification*)note
  {
     NSDictionary *userinfo = [note userInfo];
     NSError* value = [userinfo objectForKey:MPMoviePlayerThumbnailErrorKey];

     if (value!=nil)
     {
       NSLog(@"Error: %@", [value debugDescription]);
     }
     else
     {
       _imageView.image = [userinfo valueForKey:MPMoviePlayerThumbnailImageKey];
     }
  }

However I get the following error message:

  Error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1d8a63d0 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1d8b7b50 "The operation couldn’t be completed. (OSStatus error -12433.)", NSLocalizedFailureReason=An unknown error occurred (-12433)}

Anyone know the description for OSStatus Error -12433? I tried searching for documentation regarding OSStatus error codes but was unsuccessful.

Any help would be greatly appreciated.


回答1:


I had to add the times as floats so:

NSNumber *time1 = [NSNumber numberWithFloat:1.f];



回答2:


I do that using the library iFrameExtractor https://github.com/lajos/iFrameExtractor

Hope this help Good luck




回答3:


I was getting the exact same error OSStatus -12433 and I am using AVAssetImageGenerator

Turns out my issue was caused by the times I was requesting for the thumbnail. The following is an example of the time that works and a time that gave the error.

CMTime timeGivesError = CMTimeMakeWithSeconds(0.0, 0.0);
CMTime timeWorks = CMTimeMakeWithSeconds(0.0, 1.0);
CGImageRef image = [gen copyCGImageAtTime:timeWorks actualTime:&actualTime error:&error];

I would try adjusting your times and see if there is another option which will work.



来源:https://stackoverflow.com/questions/14297726/cant-get-multiple-images-from-video-using-mpmovieplayercontroller-osstatus-12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!