gpt4 book ai didi

iphone - GPUImage 问题 iPhone

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:48 26 4
gpt4 key购买 nike

我在 iphone 中使用 GPUImage 框架在视频文件中添加一些滤镜。正在成功应用过滤器。但我面临的问题是 setCompletionBlock 被连续调用两次。有人可以告诉我这段代码有什么问题吗?

- (IBAction)applyFilter:(id)sender {

NSString *path = [[NSBundle mainBundle] pathForResource:@"OriginalVideo" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
GPUImageMovie *movieFile = [[GPUImageMovie alloc] initWithURL:url];
GPUImageSepiaFilter *filter = [[GPUImageSepiaFilter alloc] init];

[movieFile addTarget:filter];

NSString *pathToMovie = [Utilities getPathForFileName:@"finalvideo.mp4"];
if ([[NSFileManager defaultManager] fileExistsAtPath:pathToMovie]) {
[[NSFileManager defaultManager] removeItemAtPath:pathToMovie error:nil];
}

unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];

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

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

[movieWriter setCompletionBlock:^{
NSLog(@"finished..............................");

[filter removeTarget:movieWriter];
[movieWriter finishRecording];
}];

[movieWriter startRecording];
[movieFile startProcessing];
}

最佳答案

movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
[movieFile prepareForImageCapture];

call these methods while applying Filter

关于iphone - GPUImage 问题 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13645018/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com