GPUImage2 icon indicating copy to clipboard operation
GPUImage2 copied to clipboard

How to tell if filtering and saving a video has finished

Open real19 opened this issue 5 years ago • 5 comments

I have a video file that I am applying a filter to first , and then saving it. I am able to save the file, but I am trying to figure out when exactly the file is saved completely so like a completion handler or something where I can do cleanup etc and next steps. Any clues as to what I need to do?

`

       movie = try MovieInput(asset: AVAsset(url: movieURL!), playAtActualSpeed: false)
      
       output = try MovieOutput(URL: newURL, size: Size(width: 1920, height: 1080))

        movie --> filter --> output

        output.startRecording()

        movie.start()`

I can't find a delegate method or notification or some sort to tell me the video processing has been completed. Any help would be greatly appreciate.. Thanks

real19 avatar Oct 06 '18 04:10 real19

If you manually finish recording, you can use the finishRecording method on your MovieOutput to provide a callback block for when that has completed.

Unfortunately, in the case of playing from a static movie file, it looks like I haven't yet brought across the delegate I had in the original GPUImage that informs you about when the movie playback has finished. Let me see about adding that.

BradLarson avatar Oct 08 '18 16:10 BradLarson

Thanks for looking into it. I also noticed that looping for video playback hasn't been fully implemented.

real19 avatar Oct 22 '18 18:10 real19

Is there any update on this?

bkunarola avatar Jul 31 '19 09:07 bkunarola

@BradLarson @real19 Hi, try to use the same code: ` let movie = try MovieInput(asset: AVAsset(url: sourceURL!), playAtActualSpeed: false)

        let output = try MovieOutput(URL: outputURL, size: Size(width: 720, height: 1280))

        movie --> output

        output.startRecording()
        movie.start()`

but get crash Fatal error: Unexpectedly found nil while unwrapping an Optional value in MovieOutput line 83 CVPixelBufferPoolCreatePixelBuffer(nil, self.assetWriterPixelBufferInput.pixelBufferPool!, &self.pixelBuffer)

Could you please, help to find my mistake

Maxim-Appicstars avatar Aug 12 '19 14:08 Maxim-Appicstars

you change outputURL to solve this error

AliJohn2050 avatar Jan 28 '20 08:01 AliJohn2050