我試着去產生從MP4視頻的圖像,但它會在iPhone上的iOS 4.2.1失敗,此錯誤AVAssetImageGenerator iOS 4.2.1錯誤?
錯誤域= AVFoundationErrorDomain代碼= -11800「的操作無法完成(AVFoundationErrorDomain錯誤 - )「UserInfo = 0x140c00 {NSUnderlyingError = 0x13e520」操作無法完成(OSStatus錯誤-12911。)「}
它在iOS 4.3.1和模擬器4.2/4.1上工作得很好。
NSString *path = [[NSBundle mainBundle] pathForResource:@"evil" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
AVAssetImageGenerator *imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
NSError *error = nil;
CGImageRef image = [imageGenerator copyCGImageAtTime:asset.duration actualTime:nil error:&error];
if(image == nil) {
NSLog(@"%@", error);
}
當我通過AVURLAsset加載並將其分配給AVPlayer時,我的第一個想法是,但視頻確實播放。該錯誤似乎與圖像生成器有關。我也嘗試過.mov和一個沒有音軌的mp4,只是爲了看看它是否與格式有關。 – 2011-04-13 15:12:51