【发布时间】:2013-10-31 15:59:31
【问题描述】:
我使用的是 GPUImage library here ,并且有很多示例可以提供帮助,但是我在使用过滤器时发现了一件事,它与 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];
}
感谢任何帮助。
谢谢。
【问题讨论】:
-
我看不到与 SimpleVideoFileFilter 示例应用程序相同的行为,它就是这样做的。如果将滑块移到那里,过滤器会随着正在播放的视频动态更新。确保您的滑块确实向您的回调方法发送了具有正确值 (0.0-1.0) 的正确更新事件。
-
@BradLarson 是的,该示例工作正常,因为它使用“GPUImageVideoCamera”,但我没有在这里使用相机,我正在尝试播放应用了过滤器的视频,效果很好,但是当我更改了不起作用的过滤器的值。是的,正如您所提到的,我得到的值是正确的..
-
不,SimpleVideoFileFilter 使用 GPUImageMovie。具体看那个。就像我说的,它在那里按预期工作。
-
@BradLarson 所以我的代码应该可以正常工作,对吧?我将再次检查滑块值.. 感谢您的见解..
标签: ios image-processing video-processing gpuimage