2

我正在开发一个使用 GPUImage 框架的应用程序。我想使用 GPUImageWhiteBalanceFilter 来调整白平衡并使用 uiElement blend 记录一些水印,它可以工作,但是在 iphone 4s 中捕获 1080p 视频时帧速率很差。代码如下,任何人都可以提供帮助。

if (filter==nil) {
    filter = [[GPUImageWhiteBalanceFilter alloc] init];
}
[((GPUImageWhiteBalanceFilter *)filter) setTemperature:3000];
[videoCamera addTarget:filter];
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
blendFilter.mix = 0.8;

NSDate *startTime = [NSDate date];

UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 240.0f, 320.0f)];
timeLabel.font = [UIFont systemFontOfSize:17.0f];
timeLabel.text = @"Time: 0.0 s";
timeLabel.textAlignment = UITextAlignmentCenter;
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.textColor = [UIColor whiteColor];

uiElementInput = [[GPUImageUIElement alloc] initWithView:timeLabel];

[filter addTarget:blendFilter];
[uiElementInput addTarget:blendFilter];

[blendFilter addTarget:filterView];

__unsafe_unretained GPUImageUIElement *weakUIElementInput = uiElementInput;

[filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){

    timeLabel.text = [NSString stringWithFormat:@"Time: %f s", -[startTime timeIntervalSinceNow]];
    [weakUIElementInput update];
}];


NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/CPMovie.mov"];
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];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(videoDimensions.width , videoDimensions.height)];
//[videoCamera addTarget:movieWriter];
//to record filtered video
[blendFilter addTarget:movieWriter];
[videoCamera startCameraCapture]; 
4

0 回答 0