3
Documents/folder에 저장된 비디오에서 비디오 축소판을 가져 와서 UITableViewCell의 UIImageView에 표시하려고합니다. 내가 그것을 사용하고 어디에비디오 축소판을 가져 오려고 시도합니다.
- (UIImage*) thumbnailImageForVideo:(NSURL *)sourceURL
{
AVAsset *asset = [AVAsset assetWithURL:sourceURL];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
NSError *err = NULL;
CMTime time = CMTimeMake(1, 1);
CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:&err];
NSLog(@"err==%@, imageRef==%@", err, imageRef);
UIImage *thumbnail = [[UIImage alloc] initWithCGImage:imageRef];
CGImageRelease(imageRef); // CGImageRef won't be released by ARC
return thumbnail;
}
그리고 여기에 있습니다 : : 여기 썸네일을 얻을 내 기능입니다
는- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LibraryCell *libraryCell = [tableView dequeueReusableCellWithIdentifier:@"LibraryCell" forIndexPath:indexPath];
NSString *videoPath = [NSString stringWithFormat:@"%@/%@", [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"], [libraryFiles objectAtIndex:indexPath.item]];
libraryCell.itemImage.image = [self thumbnailImageForVideo:[NSURL URLWithString:videoPath]];
return libraryCell;
}
응용 프로그램은 충돌하지 않습니다하지만 이미지가 없습니다. 콘솔에 표시되는 내용입니다.
2013-04-13 23:44:46.828 GeekOut[14433:907] err==Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo=0x1f0b4610 {NSUnderlyingError=0x1f0b3220 "The operation couldn’t be completed. (OSStatus error -12935.)", NSLocalizedDescription=unknown error}, imageRef==(null)
2013-04-13 23:44:46.859 GeekOut[14433:907] err==Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo=0x1dd8c660 {NSUnderlyingError=0x1dd8c5c0 "The operation couldn’t be completed. (OSStatus error -12935.)", NSLocalizedDescription=unknown error}, imageRef==(null)
2013-04-13 23:44:46.893 GeekOut[14433:907] err==Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo=0x1f0bec80 {NSUnderlyingError=0x1f0be9b0 "The operation couldn’t be completed. (OSStatus error -12935.)", NSLocalizedDescription=unknown error}, imageRef==(null)