CMSampleBufferRef的缓冲区大小 [英] Buffer size of CMSampleBufferRef

查看:314
本文介绍了CMSampleBufferRef的缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从AVFoundation回调中获取CMSampleBufferRef的大小

I am trying to get the size of CMSampleBufferRef from AVFoundation call-back

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

根据文档如果我正确理解它,则应该使用此方法来获取缓冲区大小.但 我总是从返回中得到0.并说如果此CMSampleBuffer中没有样本大小,则将返回大小为0."在这种情况下,我想知道AVFoundation框架是否不提供缓冲区大小信息或我误解了文档.

If I understand it correctly, I should use this method to get buffer size. But I always got 0 from the return. and It is said that "If there are no sample sizes in this CMSampleBuffer, a size of 0 will be returned." In this case, I wonder if AVFoundation framework does not provide a buffer size information or I mis-understand document.

一个后续问题: 顺便说一句,我想知道在这种情况下是否可以使用

A follow up question: By the way, I wonder in this case if I could use

CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

从pixelBuffer获取sampleBuffer的大小吗?

from pixelBuffer to get the size of sampleBuffer?

推荐答案

如何创建AVCaptureSession?

How do you create your AVCaptureSession?

基本上,CMSampleBuffer可以包含多个信息.

Basically a CMSampleBuffer can contain multiple information.

  • 原始图像缓冲区(您可以使用CMSampleBufferGetImageBuffer提取)
  • 音频缓冲区(必须使用CMSampleBufferGetBlockBuffer提取)
  • CoreVideo编码的图像数据缓冲区(还必须使用CMSampleBufferGetBlockBuffer提取)

因此,您应该首先检查captureoutput是否是您想要的,如果是并且您希望获得图像,则应将图像获取为CVPixelBufferRef,然后使用CVPixelBufferGetDataSize检查图像上的数据大小.

So you should first check if the captureoutput is what you wanted, and if it is and you expect an image, then you should get the image as CVPixelBufferRef then check the data size on the image using CVPixelBufferGetDataSize

这篇关于CMSampleBufferRef的缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆