GPUImagevideofilter设置亮度不起作用
//整个代码看起来不错,但是movieWriter – setCompletionBlock行没有被编译。 不知道是什么问题。
我试图从过去3天解决,但没有得到它的成功工作。
-(IBAction)setBrightness:(id)sender { sleep(1); NSURL *sampleURL = [NSURL URLWithString:_videoURLPath]; movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL]; movieFile.runBenchmark = YES; movieFile.playAtActualSpeed = NO; filterView = (GPUImageView *)gpuView; filter=[[GPUImageBrightnessFilter alloc]init]; [movieFile addTarget:filter]; [filter addTarget:filterView]; [(GPUImageBrightnessFilter *)filter setBrightness:brightValue]; 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];enter code here movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(320.0, 320.0)]; [filter addTarget:movieWriter]; movieWriter.shouldPassthroughAudio = NO; movieFile.audioEncodingTarget = movieWriter; [movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter]; [movieWriter startRecording]; [movieFile startProcessing]; [movieWriter setCompletionBlock:^{ [filter removeTarget:movieWriter]; [movieWriter finishRecording]; dispatch_async(dispatch_get_main_queue(), ^{ [_toolDelegate stringPathOfFilteredVideoFromTool:pathToMovie]; [self.navigationController popViewControllerAnimated:YES]; }); }]; }
这对我有效。
[movieWriter setCompletionBlock:^{ [filter removeTarget:movieWriter]; [movieWriter finishRecording]; }];
只需用下面的代码replace。
dispatch_async(dispatch_get_main_queue(), ^{ [filter removeTarget:movieWriter]; [movieWriter finishRecording]; NSLog(@"aa2233453546565"); });