Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
639 views
in Technique[技术] by (71.8m points)

ios - GPUImage video filter set brightness not working

//The whole code is looking fine, but movieWriter - setCompletionBlock lines are not getting compiled. Doesn't know what is the problem in it.

I tried to solve out since last 3 days but am not getting it successfully working.

-(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];

        });
    }];
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This worked for me.

[movieWriter setCompletionBlock:^{

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

Just replace above with below one.

dispatch_async(dispatch_get_main_queue(), ^{
    [filter removeTarget:movieWriter];
    [movieWriter finishRecording];
    NSLog(@"aa2233453546565");        
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...