你如何使用GPUImage中的GPUImageMovieComposition?

时间:2013-10-16 17:53:47

标签: ios objective-c gpuimage

我无法弄清楚如何将GPUImageMovieComposition与GPUImageMovieWriter一起使用(来自GPUImage),是否有关于如何使用它的示例?

这是我尝试过的,我测试过composition,videoComposition和audioMix是有效的:

movieFile = [[GPUImageMovieComposition alloc] initWithComposition:composition andVideoComposition:videoComposition andAudioMix:audioMix];
filter = [[GPUImagePixellateFilter alloc] init];

[movieFile addTarget:filter];

GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];

NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];

movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 480.0)];
[filter addTarget:movieWriter];

movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

[movieWriter startRecording];
[movieFile startProcessing];

[movieWriter setCompletionBlock:^{
    [filter removeTarget:movieWriter];
    [movieWriter finishRecording];
}];

提前谢谢!

1 个答案:

答案 0 :(得分:0)

用这个替换你的movieWriter实例化的机会有用吗?

movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:fileURL size:CGSizeMake(640.0, 480.0) fileType:AVFileTypeQuickTimeMovie outputSettings:nil];

进一步的问题,电影文件是否在设备上正常播放,而你只是没有运气存储文件?

如果是这样,是因为您正在iTunes中的“apps”标签下查找该文件,但是您没有在“自定义iOS目标属性”中将Application supports iTunes file sharing标记设置为{{1} }

如果这两种情况都不合适,究竟什么不适合你呢?