Reputation: 631
I am trying to process a video by adding a filter between GPUImageMovie and GPUImageMovieWriter. However, I got a trouble before adding a custom filter.
Here is my testing code.
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"Documents/test" withExtension:@"mov"];
movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/output.mov"];
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(1280.0, 720.0)];
[movieFile addTarget:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{
[movieFile removeTarget:movieWriter];
[movieWriter finishRecording];
}];
I got a error message like this
uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetReader initWithAsset:error:] invalid parameter not satisfying: asset != ((void*)0)'
, and there is a file named output.mov created under Documents folder with size 0.
What can I do to fix this simple task?
Upvotes: 0
Views: 1543
Reputation: 704
This error means that the sample file is not found or it's size is zero.
I believe you are mixing up the bundle files with the sandbox files. Where is your test.mov file? If it is in the bundle (i.e. added to the project files) then you should use:
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mov"];
Even if it is under a folder named Documents. But if it is in the sandbox files of the app, then you should use:
NSString *pathToSample = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.mov"];
NSURL *sampleURL = [NSURL fileURLWithPath:pathToSample];
Upvotes: 1
Reputation: 170317
Your problem appears to be here:
[pixellateFilter addTarget:movieWriter];
[movieFile addTarget:movieWriter];
You're adding both the filter and movie source to the movie writer. I think what you mean to do is this:
[movieFile addTarget:pixellateFilter];
[pixellateFilter addTarget:movieWriter];
Upvotes: 1