사진/비디오 필터 효과 프로젝트를 작업하고 있습니다. 효과를 만들기 위해 GPUImage 프로젝트를 사용하고 있습니다. 그것은 사진을 위해 잘 작동합니다. 이제 나는 비디오에도 똑같은 효과를 줄 필요가있다. 초당 30 프레임의 비디오 이미지를 가져옵니다. 이제 1 분 동영상에 대해 약 1800 개의 이미지를 필터링했습니다. 및 필터링, 각 이미지에 대한 GPUImagePicture 및 GPUImageSepiaFilter 클래스를 할당하고 그들을 manully. 그러나 이러한 할당은 해제되지 않으며 메모리 경고로 인해 약 20 초의 비디오 응용 프로그램 충돌로 처리됩니다. 모든 이미지에 필터를 만들기 위해 GPUImagePicture 및 Filter 클래스를 한 번 할당 할 수 있습니까? 그렇다면 어떻게? 매우 도움이 될 것이라고 말해주세요. 여기 내 코드는 무엇을하고 있니? ...GPUImageFilter를 여러 번 할당하면 응용 프로그램이 충돌 함
get 이미지 방법은 초당 30 회 호출되고 응용 프로그램 문서 디렉토리에서 이미지를 가져 와서 NSTimer에 의해 호출되어 - (void) imageWithEffect : (UIImage *) 이미지 메서드입니다.
-(void)getImage
{
float currentPlayBacktime = slider.value;
int frames = currentPlayBacktime*30;
NSString *str = [NSString stringWithFormat:@"image%i.jpg",frames+1];
NSString *fileName = [self.imgFolderPath stringByAppendingString:str];
if ([fileManager fileExistsAtPath:fileName])
[self imageWithEffect:[UIImage imageWithContentsOfFile:fileName]];
}
- (void)imageWithEffect:(UIImage *)image
{
GPUImagePicture *gpuPicture = [[GPUImagePicture alloc]initWithImage:img] ;
GPUImageSepiaFilter *filter = [[[GPUImageSepiaFilter alloc]init] autorelease];
gpuPicture = [gpuPicture initWithImage:image];
[gpuPicture addTarget:filter];
[gpuPicture processImage];
playerImgView.image = [filter imageFromCurrentlyProcessedOutputWithOrientation:0];
[gpuPicture removeAllTargets];
[filter release];
[gpuPicture release];
}
의견을 보내 주셔서 감사합니다. Brad. 그러나 나는 나의 요구 사항에서, 나는 완전한 비디오에 필터를 만들 필요가 없었기 때문에 정지 영상을 작업하고있다. 1 분 영상 감도는 처음 10 초, 25-30 초, 40-50 초이다. 그래서 나는 아직도 정지 이미지를 만들고있다. – Surjeet
브래드가 제안한 GPUImageMovie 또는 GPUImageVideoCamera 클래스를 사용하고 GPUImagePipeline에 필터를 넣은 다음 10 초, 25 초, 30 초 등으로 필터 배열간에 전환하는 것이 좋습니다. Brad가 설명하는대로 필터링 된/필터링되지 않은 필터와 여러 단계의 성능 사이의 전환. –
[_pipeline replaceAllFilters : filters] 여기서 _pipeline은 GPUImageFilterPipeline의 인스턴스입니다. –