GPU Image Filter disables audio in iOS

社会主义新天地 提交于 2019-12-08 13:29:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!