gpt4 book ai didi

ios - 如何将带有图像数据的 CMSampleBuffer 转换为适合通过网络连接发送的格式?

转载 作者:行者123 更新时间:2023-11-28 13:51:55 28 4
gpt4 key购买 nike

我想通过网络连接发送视频流的帧,所以我实现了 AVCaptureVideoDataOutputSampleBufferDelegate 函数:

func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)

我应该如何将 CMSampleBuffer 转换为数据作为 NWConnection 函数:

func send(content: Data?, contentContext: NWConnection.ContentContext = default, isComplete: Bool = default, completion: NWConnection.SendCompletion)

我正在使用的网络需要数据作为其内容参数吗?

最佳答案

您可能希望在通过网络发送视频帧之前对其进行压缩,因为未压缩的视频帧可能需要比可用带宽更多的带宽。你会想使用硬件压缩器来提高速度。

您可以使用 the VideoToolbox framework 访问硬件压缩器和解压缩器.

您应该观看 WWDC 2014 session 513,“Direct Access to Video Encoding and Decoding” .这是介绍中的引述:

And accompanying that, there's the case where you have a stream of images coming in from the camera or someplace else and you'd like to compress those but get direct access to those compressed sample buffers so that you can send them out over the network or do whatever you like with them.

您可以在 ASCIIwwdc 找到 session 记录.

关于ios - 如何将带有图像数据的 CMSampleBuffer 转换为适合通过网络连接发送的格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54486598/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com