I have created video using AVFoundation and now I want to edit it via GPUImage framework.
I have set all the setting as per mention here. After seeing his example of "SimpleVideoFileFilter" I have just copied his code and replace my Assets URL for Video. Here is the code.
movieFile = [[GPUImageMovie alloc] initWithURL:player.contentURL];
pixellateFilter = [[GPUImagePixellateFilter alloc] init];
[movieFile addTarget:pixellateFilter];
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)];
[pixellateFilter addTarget:movieWriter];
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
NSLog(@"precess started");
[movieWriter setCompletionBlock:^{
[pixellateFilter removeTarget:movieWriter];
[movieWriter finishRecording];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"completed");
});
}];
But I'm getting following error.
Please help me to solve this issue.
By reading this I knew that this error occur when video has no audio.
Same issue I have. I have no Audio my asset(Video). So facing this error.
To solve this error I just replaced from
movieFile.audioEncodingTarget = movieWriter;
to
movieFile.audioEncodingTarget = nil;
and code works fine.