在使用 AVFoundation 和 AVCamRecorder 录制电影后,我正在推送一个新的 UIViewController。
目前,我正在从保存电影的 URL 播放电影,效果很好。我在理解如何将视频从 URL 转换为动画 gif 时遇到了很大的困难。
I'm 很新到 Objective C 并成功创建了一个漂亮的自定义录像机,但现在我对下一个作品感到气馁。
I have
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];
}
我尝试过一些事情
AVURL资产
and
AVAsset图像生成器
但我无法输出任何东西。我想知道步骤,如果可能的话,我想知道一些关于如何将帧提取到动画 gif 中的示例。感谢您阅读我的问题! :)
答案是使用CVPixelBuffer
在生成的视频上将图像资源取出并放入内存,然后将图像添加到NSDictionary
并从存储的图像创建 gif。
如何使用CVPixelBuffer
如何将 CVPixelBuffer 转换为 UIImage? https://stackoverflow.com/questions/8072208/how-to-turn-a-cvpixelbuffer-into-a-uiimage
如何从字典中获取存储的图像并创建 gif:
通过 iOS 创建并导出 gif 动画? https://stackoverflow.com/questions/14915138/create-and-and-export-an-animated-gif-via-ios
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)