2013-01-12 15 views
7

Tôi đang cố gắng trích xuất nhiều hình ảnh từ một tệp video đã chọn bằng MPMoviePlayerController. Dưới đây là mã tôi đã viết.Không thể nhận nhiều hình ảnh từ video bằng MPMoviePlayerController. OSStatus -12433

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]; 

Đây là handler cho thông báo

-(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]; 
    } 
    } 

Tuy nhiên tôi nhận được thông báo lỗi sau:

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

Bất cứ ai biết mô tả cho OSStatus Lỗi -12.433? Tôi đã thử tìm kiếm tài liệu liên quan đến mã lỗi OSStatus nhưng không thành công.

Mọi trợ giúp sẽ được đánh giá cao.

Trả lời

0

tôi đã nhận được cùng một lỗi chính xác OSStatus -12433 và tôi đang sử dụng AVAssetImageGenerator

Hóa ra vấn đề của tôi đã gây ra vào những lần tôi yêu cầu hình thu nhỏ. Sau đây là ví dụ về thời gian hoạt động và thời gian đưa ra lỗi.

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

Tôi sẽ thử điều chỉnh thời gian của bạn và xem có tùy chọn nào khác hoạt động không.

3

tôi đã có thêm thời gian như trôi nổi như vậy:

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

Điều này làm cho nó hoạt động cho tôi. [self.videoPlayer requestThumbnailImagesAtTimes: @ [@ (1.f)] timeOption: MPMovieTimeOptionNearestKeyFrame]; – user1270061

Các vấn đề liên quan