1

我不知道如何将 GPUImageMovieComposition 与 GPUImageMovieWriter (来自GPUImage)一起使用,有没有关于如何使用它的示例?

这是我尝试过的,我测试过合成、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];
}];

先感谢您!

4

1 回答 1

0

任何机会用这个替换你的movieWriter实例有帮助吗?

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

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

如果是这样,是不是因为您正在 iTunes 中的“应用程序”选项卡下查找文件,但您没有Application supports iTunes file sharing在“自定义 iOS 目标属性”中将标志设置为YES

如果这两个都偏离了,那么究竟有什么不适合你?

于 2013-10-24T04:42:08.387 回答