现在的位置: 首页 > 综合 > 正文

取视频的第一帧作为初始页面

2013年08月19日 ⁄ 综合 ⁄ 共 935字 ⁄ 字号 评论关闭

        NSString *url = [Utils applicationCachesDirectory:self.videourl];
        url = [Utils applicationDocumentsDirectory:self.videourl];
        NSURL *videoURL = [NSURL fileURLWithPath:url];
        NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
                                                         forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
        AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:videoURL options:opts];
        //NSLog(@"视频的路径是:%@", videoURL);
        AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];
        generator.appliesPreferredTrackTransform = YES;
        generator.maximumSize = CGSizeMake(360.0f, 480.0f);
        NSError *error = nil;
        
        /*** Returns a CGImage for the asset at or near a specified time. */
        /*** - (CGImageRef)copyCGImageAtTime:(CMTime)requestedTime actualTime:(CMTime *)actualTime error:(NSError **)outError */
        CGImageRef cgImg = [generator copyCGImageAtTime: CMTimeMake(1, 1) actualTime:NULL error:&error];

抱歉!评论已关闭.