새로운 GPUImageUIElementFilter
의 몇 가지 예를 살펴본 결과 디스크에서 가져온 비디오에 적용하려고 시도했지만 대신 "흰색 화면"비디오가 나타납니다. 나는 다른 필터 (세피아, pixelate)와 코드를 실행 해봤지만, 잘 작동하는 것 같지만, UI 요소와 블렌딩이 실패합니다.GPUImageUIElementFilter가 흰색 화면으로 비디오를 반환합니다.
여기 내 코드입니다 :
//Declared in interface
@property(nonatomic, strong) GPUImageMovieWriter *movieWriter;
@property(nonatomic, strong) GPUImageMovie *movieFile;
@property(nonatomic, strong) GPUImageFilter *blendFilter;
@property(nonatomic, strong) GPUImageUIElement *uiElementFilter;
- (void)videoOutputOverlay {
self.movieFile = [[GPUImageMovie alloc] initWithURL:self.post.url];
self.movieFile.runBenchmark = YES;
self.movieFile.playAtActualSpeed = YES;
self.blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
((GPUImageAlphaBlendFilter *)self.blendFilter).mix = 1.0;
self.drawingView.backgroundColor = [UIColor clearColor];
self.uiElementFilter = [[GPUImageUIElement alloc] initWithView:self.drawingView];
[self.movieFile addTarget:self.blendFilter];
[self.uiElementFilter addTarget:self.blendFilter];
// In addition to displaying to the screen, write out a processed version of the movie to disk
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Output.m4v"];
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];
self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 480.0)];
[self.blendFilter addTarget:self.movieWriter];
// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
self.movieWriter.shouldPassthroughAudio = YES;
self.movieFile.audioEncodingTarget = self.movieWriter;
[self.movieFile enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];
[self.movieWriter startRecording];
[self.movieFile startProcessing];
__weak PostPreviewViewController *weakSelf = self;
[self.movieWriter setCompletionBlock:^{
[weakSelf.blendFilter removeTarget:weakSelf.movieWriter];
[weakSelf.movieWriter finishRecording];
UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, NULL, NULL);
NSLog(@"completed saving movie");
}];
}
이 거의 온라인 거기에 몇 가지 예에서 동일하게 복사 된 모든이며, 주요 차이점은 내가 비디오를 살 파일을 사용하고 있다는 점이다.
내 "카메라 롤"에 보낸 비디오에, 나는 오디오를들을 수 + 모든 다른 필터와 함께 일했다, 그래서 나는 비디오가 올바로로드 (플러스 수출에 오류 못하고)
I입니다 확신 내가 필터/타겟을 설정하는 방식에 뭔가 잘못되었다고 가정합니다.
도움을 주시면 감사하겠습니다. 감사합니다