码迷,mamicode.com
首页 > 移动开发 > 详细

IOS如何创建视频缩略图片

时间:2015-12-23 19:44:16      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

IOS如何创建视频缩略图片

技术分享

//将完整的图片和缩略后的图片写入临时文件夹中
     NSData *pngImage = UIImagePNGRepresentation(thumbnail);
     if ([pngImage writeToFile:[NSString stringWithFormat:@"%@/tempImage.png",TEMP_FOLDER] atomically:YES]) {
 

    UIImage *myThumbNail = [[UIImage alloc] initWithData:pngImage];

    UIGraphicsBeginImageContext(CGSizeMake(60.0, 60.0));

    [myThumbNail drawInRect:CGRectMake(0.0, 0.0, 60.0, 60.0)];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

    UIImageView *thumbView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 60.0)];

    thumbView.image = newImage;

    [self.view addSubview:thumbView];

    

    NSData *thumbData = UIImagePNGRepresentation(newImage);

        if ([thumbData writeToFile:[NSString stringWithFormat:@"%@/tempImageThumb.png"] atomically:YES]) {

            NSLog(@"thumb written!");

        }

        

    }

 

视频图片可以从视频中截取

 

_moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:movieUrl];

    UIImage *thumbnail = [_moviePlayerthumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame

IOS如何创建视频缩略图片

标签:

原文地址:http://www.cnblogs.com/linxiu-0925/p/5070958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!