ios - 使用 AVPlayer 播放 CMSampleBufferRef

标签 ios macos avfoundation avplayer

我正在开发一个 OSX 视频编辑应用程序,并且在一个数组中有一组 CMSampleBufferRef,代表视频的每一帧。

我想使用 AVPlayer 渲染视频预览 - 是否可以将这些样本直接输入到 AVPlayer 中?

我看过大部分 AVFoundation 类。我知道我可以使用 AVAssetWriter 来写入文件,但我想避免这种情况,因为用户仍将进行更多编辑(拥有原始帧数据真是太好了)。

有什么想法吗?

最佳答案

是的,你可以。

首先,你应该转换CMSampleBufferRefCGImageRef , 这将允许您在屏幕上显示帧样本。

This answer具有执行此操作所需的所有代码。

即将玩AVPlayer ,我不确定你是否真的需要这样做,因为你可以通过你的 CMSampleBufferRef 获得完全访问权限array 并且您能够正确地转换和渲染这些示例,我认为没有必要将这些示例放在 AVPlayer 中,相反,您可以直接渲染 CGImageCALayer .

希望对您有所帮助。

关于ios - 使用 AVPlayer 播放 CMSampleBufferRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30147204/

相关文章:

ios - 实例化后如何推送导航 Controller

ios - 静默配对 iBeacon

ios - AVSpeechUtterance 作为 UILocalNotification 声音

macos - Vim:如何从 tabview 切换回垂直拆分

iOS 8.4 特定 : AVPlayer not playing both video & audio and no errors

ios - Sprite Kit - 改变场景时继续播放音频

ios - 如何在 TableViewCell 中将 UIButton 居中?

C++/Qt : How can I detect when a hostname or IP address refers to the current system?

macos - 通过 macOS native 应用程序中的 SwiftUI WKWebView 调用时,如何使文件打开对话框正常工作?

iphone - 如何使用 AV Foundation 连续捕获图像?