我正在使用AVFoundation和AVCamRecorder录制视频后,推送一个新的UIViewController。
目前,我正在从保存电影的URL中播放电影,并且它运行良好。但是,我在如何将视频从URL转换为动画gif方面遇到了很大的麻烦。
我对Objective C相当陌生,并且成功创建了一个漂亮的自定义视频录制器,但现在在这个下一步上感到沮丧。
我有
SecondViewController.h
@interface SecondViewController : UIViewController
@property NSURL *videoURL;
@end
SecondViewController.m
#import "SecondViewController.h"
#import "FirstViewController.h"
#import "CaptureManager.h"
#import "AVCamRecorder.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface SecondViewController ()
@property (nonatomic, strong) CaptureManager *grabFile;
@property (nonatomic, strong) MPMoviePlayerController *movie;
@end
@implementation SecondViewController
- (void)viewDidLoad
{
self.movie = [[MPMoviePlayerController alloc] initWithContentURL:self.videoURL];
_movie.view.frame = CGRectMake(0.0, 64.0, 320.0, 320.0);
_movie.movieSourceType = MPMovieSourceTypeFile;
_movie.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:_movie.view];
[_movie play];
}
我尝试使用
AVURLAsset
和
AVAssetImageGenerator
但我无法进一步输出任何内容。我想知道提取帧并将其转换为动态gif的步骤,如果可能的话,请给出一些示例代码。感谢阅读我的问题! :)