【问题标题】:Get current video duration from CMSampleBufferRef从 CMSampleBufferRef 获取当前视频时长
【发布时间】:2015-08-03 07:22:59
【问题描述】:

如何在委托方法中从 CMSampleBufferRef 获取当前录制的视频时长

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

请用示例代码指导

【问题讨论】:

    标签: ios avfoundation cmsamplebufferref


    【解决方案1】:

    您需要的详细信息在视频元数据中。要获取视频元数据,您可能需要将您的 CMSampleBuffer 转换为 CVPixelBuffer

    CMSampleBuffer 是 Core Foundation 风格的不透明类型;一个实例包含一帧视频数据的样本缓冲区。 CVPixelBuffer 是来自采样缓冲区的核心视频像素。

    您可以使用下面的CMSampleBufferGetImageBuffer:从样本缓冲区中获取像素缓冲区

    CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(<#A CMSampleBuffer#>);

    一旦获得像素缓冲区,您就可以获取视频元数据,例如时间和格式信息。

    要获取时间信息,请分别使用CMSampleBufferGetPresentationTimeStampCMSampleBufferGetDecodeTimeStamp

    更多信息请阅读Representations of Media

    【讨论】:

      猜你喜欢
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      • 1970-01-01
      • 1970-01-01
      • 2011-11-14
      • 2016-07-29
      • 2019-09-27
      相关资源
      最近更新 更多