BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.88k stars 611 forks source link

App crashing while applying filter #276

Open Rahish opened 6 years ago

Rahish commented 6 years ago

Hello @BradLarson ,

Whenever we apply any filter on video will get this message.

"Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] A pixel buffer cannot be appended when readyForMoreMediaData is NO.'"

We need your assistance in order to resolve this issue.

Thanks.

tuyenntq commented 3 years ago

I got this error when set playAtActualSpeed = false Change co on MovieInput to like bellow:

if (playAtActualSpeed) { // Do this outside of the video processing queue to not slow that down while waiting let currentSampleTime = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer) let differenceFromLastFrame = CMTimeSubtract(currentSampleTime, previousFrameTime) let currentActualTime = CFAbsoluteTimeGetCurrent()

                let frameTimeDifference = CMTimeGetSeconds(differenceFromLastFrame)
                let actualTimeDifference = currentActualTime - previousActualFrameTime

                if (frameTimeDifference > actualTimeDifference) {
                    usleep(UInt32(round(1000000.0 * (frameTimeDifference - actualTimeDifference))))
                }

                previousFrameTime = currentSampleTime
                previousActualFrameTime = CFAbsoluteTimeGetCurrent()
            } else {
                let currentSampleTime = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer)
                let differenceFromLastFrame = CMTimeSubtract(currentSampleTime, previousFrameTime)
                let currentActualTime = CFAbsoluteTimeGetCurrent()

                let frameTimeDifference = CMTimeGetSeconds(differenceFromLastFrame)
                let actualTimeDifference = currentActualTime - previousActualFrameTime

                if (frameTimeDifference > actualTimeDifference) {
                    usleep(UInt32(round(1000.0 * (frameTimeDifference - actualTimeDifference))))
                }

                previousFrameTime = currentSampleTime
                previousActualFrameTime = CFAbsoluteTimeGetCurrent()
            }