Hen*_*rik 6 core-image swift phlivephoto
我正在使用.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
}
Run Code Online (Sandbox Code Playgroud)
恐怕在这种情况下无法并行化帧处理。你必须记住:
expensiveOperation
并没有真正发生在frameProcessor
块中,因为实际渲染是由此范围之外的框架处理的。