【问题标题】:Importance of AVAssetWriterInputPixelBufferAdaptor in AVAssetWriterAVAssetWriterInputPixelBufferAdaptor 在 AVAssetWriter 中的重要性
【发布时间】:2018-04-06 06:32:15
【问题描述】:

我正在尝试使用AVAssetWriter 输出从相机捕获的视频。

我正在关注一些不使用 AVAssetWriterInputPixelBufferAdaptor (Record video with AVAssetWriter) 和一些使用 (AVCaptureSession only got video buffer) 的示例。

根据 Apple 的参考资料,我将AVAssetWriterInputPixelBufferAdaptor(或CVPixelBuffer, CVPixelBufferPool)的用途大致解释为一种在内存中缓冲传入像素的有效方法。在实践中,使用AVAssetWriter 编写视频输出时使用它有多重要?我似乎可以在不使用适配器的情况下获得一个基本版本,但我想更多地了解使用AVAssetWriterInputPixelBufferAdaptor 的好处/意图。

【问题讨论】:

    标签: ios video avassetwriter


    【解决方案1】:

    多年来,我一直在使用没有 PixelBufferAdaptor 的视频录制,没有任何问题。我基本上使用这段代码:

    - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer  fromConnection:(AVCaptureConnection *)connection{
         if (videoWriterInput.readyForMoreMediaData) {
             [videoWriterInput appendSampleBuffer:sampleBuffer];
         }
    }
    

    我的看法是,由于 CMSampleBufferRef 包含时间信息,因此可以直接写入。而如果您有 CVPixelBuffer,则必须通过适配器添加计时信息。所以如果你在写之前做一些图像处理,你最终会得到一个 CVPixelBuffer 并且必须使用适配器。如果您的处理需要时间,适配器可能还会为 CVPixelBuffer 添加一些缓冲功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多