Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
633 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 Answer

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");        
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...