问题
I've tried the examples from the GPUImage library. I tried the 'SimpleVideoFileFilter' but all I see its black screen with the slider. I tried to do the same by my self, I got the images working perfect. but I can't really understand the videos process. the examples taking the videos from the project itself ? folder from the mac ? or its from the iPhone's videos ? I don't have Apple Developer account, so I can't really test it on my device. I found way to put an random (.m4v) file in the iPhone Simulator, and tried to play/filter the video.
anyone had this issue ? I'm trying for now just to play the video from the iPhone Simulator or the resource files .. I don't really know where how its works. I tried this link, no luck.
Here is part of the example that we can find in GPUImage:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"sample_iPod" withExtension:@"m4v"];
movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
filter = [[GPUImagePixellateFilter alloc] init];
// filter = [[GPUImageUnsharpMaskFilter alloc] init];
[movieFile addTarget:filter];
// Only rotate the video for display, leave orientation the same for recording
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];
// In addition to displaying to the screen, write out a processed version of the movie to disk
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/TestMovie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 480.0)];
[filter addTarget:movieWriter];
// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{
[filter removeTarget:movieWriter];
[movieWriter finishRecording];
}];
}
simple code that should filter the video .. all I get from there is black screen with the slider ..
I'm talking about this project.
回答1:
Movie playback does not currently work within the Simulator using GPUImage. You'll need to run this on an actual device to have this work.
I'm not sure why movie files don't output anything when run from the Simulator, but you're welcome to dig into the GPUImageMovie code and see what might be wrong. Since it runs fine when operated on actual hardware, it hasn't been a priority of mine to fix.
来源:https://stackoverflow.com/questions/19932356/im-trying-to-get-the-video-filtering-working