我在GPUImage library
这里使用,并且有很多示例可以提供帮助,但是我在使用过滤器时发现了一件事,它与GPUImageVideoCamera
. 我试图对已录制的视频应用过滤器,过滤器工作正常,但是当我尝试更改过滤器的值时,它不会反映它,因为我没有使用GPUImageVideoCamera
,因为我不必录制视频,但我必须实现过滤器预览,然后应用选定的过滤器并创建一个新电影。
下面我输入我的一些代码
- (void)viewDidLoad
{
[super viewDidLoad];
//Creating Filter
filter=[[GPUImageSepiaFilter alloc] init];
//Playing Video
[self playVideo];
}
-(void)playVideo{
if(!movieFile){
movieFile = [[GPUImageMovie alloc] initWithURL:self.videoURL];
movieFile.playAtActualSpeed=YES;
movieFile.playSound=YES;
movieFile.delegate=self;
}
[movieFile addTarget:filter];
CGRect rect=self.viewMovie.frame;
rect.origin=CGPointZero;
self.filterView=[[GPUImageView alloc] initWithFrame:rect];
[self.viewMovie addSubview:self.filterView];
//Rotate the preview to fix portrait recored video to show properly
if([self.transformation isEqualToString:@"portrait"]){
self.filterView.rotation=kGPUImageRotateRight;
}
[self.filterView initMovie];
[filter addTarget:self.filterView];
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[movieFile startProcessing];
});
}
- (IBAction)sliderAction:(id)sender {
[self applySliderValue:self.slider.value];
}
//Doesn't work
-(void)applySliderValue:(float)sliderValue{
[((GPUImageSepiaFilter *)filter) setIntensity:sliderValue];
}
任何帮助表示赞赏。
谢谢。