assetwriter 时间倒退并在 gpu 图像中得到 nil 输出 swift

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

所以,我正在尝试使用 GPU 图像 2 创建视频,在电影输出中资产编写器倒退的时间和几帧后,我收到此警告。大多数时候,当我应用图像混合过滤器或视频混合过滤器时,它就会发生。

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)"}})

请帮忙解决这个问题, 我也遇到了 this answer 这可能与我的问题有关

在图像混合或视频混合 gpu 图像中需要更多时间来计算帧缓冲区的正确时间,因此您必须在 movieoutput.init() 函数和 startrecording()[=11= 之间手动创建延迟]

通过使用

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