AVPlayer给视频添加简单滤镜

黑灰滤镜,处理时内存会彪,但还在可接受范围

self.avPlayerItem.videoComposition = [AVVideoComposition videoCompositionWithAsset:self.avAsset applyingCIFiltersWithHandler:  ^(AVAsynchronousCIImageFilteringRequest *request){
      @autoreleasepool {
            NSError *err = nil;
            CIImage *ciImage = request.sourceImage;
            //灰色滤镜
            CIFilter *filter = [CIFilter filterWithName:@"CIColorMonochrome"];
            [filter setValue:ciImage forKey:kCIInputImageKey];
            [filter setValue:[CIColor colorWithRed:0.7 green:0.7 blue:0.7] forKey:kCIInputColorKey];
            [filter setValue:@1.0 forKey:kCIInputIntensityKey];
            
            CIImage *outputImage = filter.outputImage;
            if (outputImage)
              [request finishWithImage:outputImage context:nil];
            else
              [request finishWithError:err];
            
            outputImage = nil;
        }
    }];

你可能感兴趣的:(AVPlayer给视频添加简单滤镜)