BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.23k stars 4.61k forks source link

Failed when exporting a file with video watermark #2440

Open StarryThrone opened 7 years ago

StarryThrone commented 7 years ago

First, i add a video watermark into my original movie, processing by the GPUImageTwoInputFilter, which render the buffer only after received two input buffers. When i export this movie, the duration of result movie is differently with that of original movie and the images from two videos are obviously not synchronized. I did not find a appropriate way or effective API to resolve these tow problems. Here is my code.

` Code

self.exportMovie = [[SVImageMovie alloc] initWithAsset:asset];
self.exportMovie.playAtActualSpeed = NO;
self.exportMovie.runBenchmark = NO;
GPUImageOutput<GPUImageInput> *filter = [FilterManager filter];
 [self.exportMovie addTarget:filter];    
self.fileURL = [FileManager createURL];
self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:self.fileURL size:renderSize];
self.movieWriter.shouldPassthroughAudio = YES;
[filter addTarget:self.movieWriter];
[self.exportMovie enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];
self.exportMovie.audioEncodingTarget = self.movieWriter;
[self.movieWriter setCompletionBlock:^{
    UISaveVideoAtPathToSavedPhotosAlbum(weakSelf.fileURL.path, nil, nil, nil);
    [weakSelf.filter removeTarget:weakSelf.movieWriter];
    [weakSelf.movieWriter finishRecording];
    [weakSelf.waterExportMovie removeAllTargets];
    weakSelf.waterExportMovie = nil;
}];
[self.movieWriter startRecording];
[self.exportMovie startProcessing];
[self.waterExportMovie startProcessing];

`