GPUImageMovie 主要的作用是读取与解码音视频文件。它继承自GPUImageOutput,可以输出帧缓存对象,由于没有实现GPUImageInput协议,因此只能作为响应源。
-初始化。可以通过NSURL、AVPlayerItem、AVAsset初始化。
- (id)initWithAsset:(AVAsset *)asset;
- (id)initWithPlayerItem:(AVPlayerItem *)playerItem;
- (id)initWithURL:(NSURL *)url;
初始化相对简单,只是简单保存传入数据。
- (id)initWithURL:(NSURL *)url;
{
if (!(self = [super init]))
{
return nil;
}
[self yuvConversionSetup];
self.url = url;
self.asset = nil;
return self;
}
- (id)initWithAsset:(AVAsset *)asset;
{
if (!(self = [super init]))
{
return nil;
}
[self yuvConversionSetup];
self.url = nil;
self.asset = asset;
return self;
}
- (id)initWithPlayerItem:(AVPlayerItem *)playerItem;
{
if (!(self = [super init]))
{
return nil;
}
[self yuvConversionSetup];
self.url = nil;
self.asset = nil;
self.playerItem = playerItem;
return self;
}
- 其实方法
// 允许使用GPUImageMovieWriter进行音视频同步编码
- (void)enableSynchronizedEncodingUsingMovieWriter:(GPUImageMovieWriter *)movieWriter;
// 读取音视频
- (BOOL)readNextVideoFrameFromOutput:(AVAssetReaderOutput *)readerVideoTrackOutput;
- (BOOL)readNextAudioSampleFromOutput:(AVAssetReaderOutput *)readerAudioTrackOutput;
// 开始、结束、取消读取
- (void)startProcessing;
- (void)endProcessing;
- (void)cancelProcessing;
// 处理视频帧
- (void)processMovieFrame:(CMSampleBufferRef)movieSampleBuffer;
未完………….