有什么方法可以取消/停止GPUImageMovieWriter
和GPUImageMovie
运行startRecording
后startProcessing
?
问问题
1610 次
3 回答
1
最近,添加了一种新方法GPUImageMovie
,允许取消对视频文件的处理:
- (void)cancelProcessing;
这将允许您有效地取消对视频的处理,并且不再处理任何帧。
考虑到您GPUImageMovieWriter
的 completionBlock 无论如何都会被调用,因此您应该有某种标志来检查该块是为成功完成还是被取消调用。
这是一些示例代码:
- (void)processVideo
{
_wasCancelled = NO;
self.imageMovie = [self createImageMovie];
self.filter = [self createFilter];
[imageMovie addTarget:filter]
self.movieWriter = [self createMovieWriter];
[self.movieWriter startRecording];
[self.imageMovie startProcessing];
[self.movieWriter setCompletionBlock:^{
[self.filter removeTarget:movieWriter];
[self.movieWriter finishRecording];
if (!_wasCancelled) {
// Do stuff with the video
}
}];
}
- (void)cancelVideoProcessing
{
_wasCancelled = YES;
[self.imageMovie cancelProcessing];
}
于 2013-05-30T15:58:38.587 回答
0
为什么。有一个取消录制选项。
[self.movieWriter cancelRecording];
如果视频以任何方式中断,则不会保存视频。
于 2013-02-12T10:16:40.587 回答
0
假设 self.movieWriter 为 GPUImageMovieWriter,则需要在调用 startRecording 和 startProcessing 之前设置回调:
[self.movieWriter setCompletionBlock:^{
[self finishFilter];
}];
然后你可以停止图像处理:
[self.movieWriter endProcessing];
回调是:
- (void)finishFilter {
//remove all targets from your filter chain calling "removeAllTargets"
//then:
[self.movieWriter finishRecording];
self.movieWriter.completionBlock = nil;
self.movieWriter = nil;
}
于 2012-09-27T13:45:44.853 回答