How GPUImageMovie uses the initWithPlayerItem method to initialize a GPUImageMovie

How GPUImageMovie uses the initWithPlayerItem method to initialize a GPUImageMovie

- (void)setupGPUImageMovieWithPlayerItem{
    NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"aichangVideo.mp4" withExtension:nil];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:sampleURL];
    GPUImageMovie *gpuImageMovie = [[GPUImageMovie alloc] initWithPlayerItem:playerItem];
    [gpuImageMovie startProcessing];
    
    //Note that when GPUImageMovie is initialized with the initWithPlayerItem method, it needs to be called
    //replaceCurrentItemWithPlayerItem method can call outputMediaDataWillChange method to enable
    //Texture output function of GPUImageMovie
    AVPlayer *player = [[AVPlayer alloc] init];
    [player replaceCurrentItemWithPlayerItem:playerItem];
    [player play];
    
    GPUImageView *gpuImageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.width)];
    [self.view addSubview:gpuImageView];
    gpuImageView.center = self.view.center;
    
    [gpuImageMovie addTarget:gpuImageView];
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325440447&siteId=291194637