Search code examples
swiftframebuffergpuimageavassetwriter

assetwriter time going backward and get nil output in gpu image swift


so, I'm trying to create a video by using GPU image 2, and in movie output the time of asset writer going backward and after a couple of frames, I get this warning. most of the time when I apply an image blend filter or video blend filter it happens.

WARNING: Trouble appending pixel buffer at time: CMTime(value: 80, timescale: 600, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0) Optional(Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16364), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2828f7ed0 {Error Domain=NSOSStatusErrorDomain Code=-16364 "(null)"}})

please help to solve this problem, and I also come across with this answer it might be related to my problem


Solution

  • in image blend or video blend gpu image required little bit of more time to calculate the proper timestemp for framebuffer so you have to create manually delay between movieoutput.init() function and startrecording()

    by using

    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
    // your code here
    }