如何将视频转换为GIF图像在iPhone?

时间:2020-12-30 21:20:43

I am implementing one iPhone photo/Video application in which I have tried to implement below functionality.

我正在实现一个iPhone照片/视频应用程序,我在其中尝试实现以下功能。

Capture video through camera & convert in to GIF image

通过摄像机捕获视频并转换为GIF图像。

I have tried to googling but not got successed.

我试着用谷歌搜索,但没有成功。

Can any one suggest me or advice me how to achive this feature?

有没有人可以建议我或者建议我如何实现这个功能?

Thanks in advance

谢谢提前

2 个解决方案

#1


0  

Add

添加

#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/UTCoreTypes.h>

and use following delegate method of UIImagePickerViewController

然后使用UIImagePickerViewController的委托方法。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   if ([[info objectForKey:UIImagePickerControllerMediaType ] isEqualToString:@"public.movie"])
   {
     MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[info objectForKey:UIImagePickerControllerMediaURL];];
        UIImage  *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
        [player stop];
        player = nil;

     // Here your got UIImage name is 'thumbnail'
   }
}

You can get image (thumbnail) from video.

你可以从视频中得到图像(缩略图)。

#2


0  

Though this question is old, I created a library for converting videos to gifs for iOS.

虽然这个问题由来已久,但我还是创建了一个库,用于将视频转换为iOS的gif格式。

#1


0  

Add

添加

#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/UTCoreTypes.h>

and use following delegate method of UIImagePickerViewController

然后使用UIImagePickerViewController的委托方法。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   if ([[info objectForKey:UIImagePickerControllerMediaType ] isEqualToString:@"public.movie"])
   {
     MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[info objectForKey:UIImagePickerControllerMediaURL];];
        UIImage  *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
        [player stop];
        player = nil;

     // Here your got UIImage name is 'thumbnail'
   }
}

You can get image (thumbnail) from video.

你可以从视频中得到图像(缩略图)。

#2


0  

Though this question is old, I created a library for converting videos to gifs for iOS.

虽然这个问题由来已久,但我还是创建了一个库,用于将视频转换为iOS的gif格式。