问题
I have implemented Video filers using GPUImage framework and all the filters are applied, but audio is disabled if we play video with filters. But if i play the same movie url in mpmovieplayer audio is playing along with video. Below is my code:
movieFile = [[GPUImageMovie alloc] initWithURL:self.videoURL];
movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
[movieFile addTarget:filter];
[filter setInputRotation:kGPUImageRotateRight atIndex:0];
GPUImageView *view = [[GPUImageView alloc] init];
view.tag = 529;
view.frame = CGRectMake(0, 80, 768, 820);
[filter addTarget:view];
[self.view addSubview:view];
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[filter addTarget:movieWriter];
Any help to solve this problem is appreciated and thanks in advance.
回答1:
GPUImage currently has no way to play audio from a movie when displaying to the screen. Only the video frames are displayed within a GPUImageView.
You can add this functionality yourself, if you need it. I'd gladly accept a pull request with that.
来源:https://stackoverflow.com/questions/25045492/gpu-image-filter-disables-audio-in-ios