Dee*_*rma 1 core-image avfoundation ios avplayer cifilter
我使用 CoreImage 将实时效果应用于使用 AVPlayer 播放的视频。问题是当播放器暂停时,如果您使用滑块调整过滤器参数,则不会应用过滤器。
let videoComposition = AVMutableVideoComposition(asset: asset, applyingCIFiltersWithHandler: {[weak self] request in
// Clamp to avoid blurring transparent pixels at the image edges
let source = request.sourceImage.clampedToExtent()
let output:CIImage
if let filteredOutput = self?.runFilters(source, filters: array)?.cropped(to: request.sourceImage.extent) {
output = filteredOutput
} else {
output = source
}
// Provide the filter output to the composition
request.finish(with: output, context: nil)
})
Run Code Online (Sandbox Code Playgroud)
作为解决方法,我使用了这个在 iOS 12.4 之前有效的答案,但在 iOS 13 beta 6 中不再有效。寻找适用于 iOS 13 的解决方案。
在向 Apple 报告此错误并获得一些有用的反馈后,我得到了修复:
\n\nplayer.currentItem?.videoComposition = player.currentItem?.videoComposition?.mutableCopy() as? AVVideoComposition\nRun Code Online (Sandbox Code Playgroud)\n\n我得到的解释是:
\n\n\n\n\n当 AVPlayerItem\xe2\x80\x99s videoComposition 属性获取新实例时,或者即使是同一个实例,但该实例的属性已被修改时,AVPlayer 会重绘一帧。
\n
因此; 强制重绘可以通过简单地复制现有实例来创建“新”实例来实现。
\n| 归档时间: |
|
| 查看次数: |
718 次 |
| 最近记录: |