我正在使用 .frameProcessor 处理 PHLivePhoto 来修改每一帧。帧似乎是按顺序处理的,这很慢。我可以让 PHLivePhotoEditingContext.frameProcessor 来利用多个核心吗?
func processLivePhoto(input: PHContentEditingInput) {
guard let context = PHLivePhotoEditingContext(livePhotoEditingInput: input)
else { fatalError("not a Live Photo editing input") }
context.frameProcessor = { frame, _ in
let renderedFrame = expensiveOperation(using: frame.image)
return renderedFrame
}
// ...logic for saving
}
最佳答案
在这种情况下,恐怕无法并行化帧处理。你必须记住:
expensiveOperation
在 frameProcessor
中并没有真正发生无论如何阻止,因为实际渲染是由该范围之外的框架处理的。 关于swift - 在多个线程上处理实时照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58236594/