Search code examples
iosobjective-cgpuimage

How to detect when GPUImageMovie has finished processing


Is there a way to detect when GPUImageMovie has finished processing? At the minute I don't want the movie to save so there is no GPUImageMovieWriter with completion block.

self.movieFile = [[GPUImageMovie alloc] initWithURL:assetURL];

if([filterType isEqualToString:@"BigApple 1"]){

    self.lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"BigApple1.png"]];
    [self.lookupImageSource processImage];
    [self.lookupImageSource useNextFrameForImageCapture];

    filter = [[GPUImageLookupFilter alloc] init];
    [lookupImageSource addTarget:filter atTextureLocation:1];

}

[movieFile addTarget:filter];

[filter addTarget:videoWindow];

[self.imageThumbnail removeFromSuperview];

[movieFile startProcessing];

Solution

  • Solved the issue by using a timer and then checking the progress value on GPUImageMovie.

    self.sampleTimer = [NSTimer scheduledTimerWithTimeInterval:0.1f
                                                      target:self
                                                    selector:@selector(retrievingSampleProgress)
                                                    userInfo:nil
                                                     repeats:YES];
    
    - (void)retrievingSampleProgress {
    
    NSLog(@"Sample Complete:%f",self.movieFile.progress);
    
    if(self.movieFile.progress == 1){
        [self.sampleTimer invalidate];
        self.viewingSample = 0;
    }else {
        self.viewingSample = 1;
    }
    

    }