2015-08-25 63 views

回答

0
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    NSURL *urlvideo = [info objectForKey:UIImagePickerControllerMediaURL]; 
    __block NSData *movieData = [[NSData alloc]initWithContentsOfURL:urlvideo];AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:urlvideo options:nil]; 
    AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; 
    generator.appliesPreferredTrackTransform=TRUE; 


    CMTime thumbTime = CMTimeMakeWithSeconds(0,30); 

    AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){ 
     if (result != AVAssetImageGeneratorSucceeded) { 
      NSLog(@"couldn't generate thumbnail, error:%@", error); 
     } 

     UIImage *img = [UIImage imageWithCGImage:im]; 
    }; 
} 
相關問題