Ale*_*yne 3 iphone video ffmpeg
如何获取从相机胶卷或相机本身导入的视频的缩略图?
这已被问过,并已得到解答.但是,答案对我来说很糟糕.
这个线程iphone sdk> 3.0.视频缩略图?有一些选项归结为:
真的没有别的办法吗?这对SDK来说似乎是一个巨大的疏忽.我的意思是视频选择器中有缩略图,因此Apple必须做一些事情来生成这些,但不允许我们这样做?
小智 12
-(void)testGenerateThumbNailDataWithVideo {
NSString *path = [[NSBundle mainBundle] pathForResource:@"IMG_0106" ofType:@"MOV"];
NSURL *url = [NSURL fileURLWithPath:path];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
NSError *err = NULL;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
[generate release];
NSLog(@"err==%@, imageRef==%@", err, imgRef);
UIImage *currentImg = [[UIImage alloc] initWithCGImage:imgRef];
static BOOL flag = YES;
if (flag) {
NSData *tmpData = UIImageJPEGRepresentation(currentImg, 0.8);
NSString *path = [NSString stringWithFormat:@"%@thumbNail.png", NSTemporaryDirectory()];
BOOL ret = [tmpData writeToFile:path atomically:YES];
NSLog(@"write to path=%@, flag=%d", path, ret);
flag = NO;
}
[currentImg release];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6166 次 |
最近记录: |