【发布时间】:2014-04-19 16:42:01
【问题描述】:
在使用 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 中的示例。感谢您阅读我的问题! :)
【问题讨论】:
-
我认为 AVFoundation 对 GIF 格式一无所知,您可能只想从视频中提取图像(使用 AVAssetReader 或 AVAssetImageGenerator),然后使用某个库创建动画 gif。
标签: objective-c avfoundation animated-gif