问题标签 [cmsamplebufferref]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
objective-c - 了解 CMSampleBuffer 和 didOutputSampleBuffer
我试图了解它是如何CMSampleBuffer
工作的。最终,我正在寻找将CMSampleBuffer
像素(格式为kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
格式)更改为像素的最有效方法grayScale
。
最终结果将是(快速)灰度实时视频流。
我尝试了以下方法:
以某种方式假设指示像素。但从那里我有点迷路了。各位有什么建议吗?
ios - 如何创建样本缓冲区 (CMSampleBufferRef) 的实例?
我尝试编写 ios 相机,并从苹果中获取了部分代码:
我需要从程序中的任何位置调用此函数。但是因为它需要创建一个对象类型为(CMSampleBufferRef)
. 怎么做?
我试着写一些类似的东西:
但这是错误的方式。
objective-c - 通过 AVCaptureSession 视频输出了解 Metal 的使用
我试图了解CMPixelBuffer
使用 Metal 操作视频输出()的正确方法是什么。
据我了解有MTKView
。来自视频输出的每个CMPixelBuffer
都被分配给Metal Texture
. 所以最后的预览是从MTKView
?
当我在屏幕上看到最终结果时,是不是:
或者
很困惑。有人可以把东西放在现场吗?
ios - 渲染失败,因为不支持像素格式 YCC420f
我正在尝试使用以下代码段将 CVPixelBufferRef 转换为 UIImage:
我的问题是,当我在设备上运行代码时它工作正常,但在模拟器上运行时无法渲染,控制台输出以下内容:
渲染失败,因为不支持像素格式 YCC420f
有任何想法吗?
objective-c - 我无法将此objectiveC代码转换为swift
1.我正在将objective c的反向音频功能转换为swift,以便我可以将swift代码集成到我的程序中,但这几行代码无法理解
2.这是下面的objective-c代码:
avfoundation - CMSampleBufferGetImageBuffer 返回 null
我正在尝试从 CMSampleBufferRef 检索 CVPixelBufferRef 以更改 CVPixelBufferRef 以动态覆盖水印。
我正在使用CMSampleBufferGetImageBuffer(sampleBuffer)
以实现这一目标。我正在打印返回的 CVPixelBufferRef 的结果,但它始终为空。
我有什么我想念的吗?
ios - 如何将 CMSampleBuffer 保存到来自 didOutputSampleBuffer 的 CFArrayRef (或其他容器)
我尝试从 didOutputSampleBuffer 中保存 CMSampleBuffer,作为 iOS 开发人员文档,我将其复制到 CFArrayRetainCallBack 中,如下所示:
我使用如下数组:
有人有更好的方法来做到这一点或任何建议?
非常感谢。
macos - CMBlockBuffer ownership in CMSampleBuffer
I'm writing code to decompress a native annex-B H.264 stream, and I'm going through the process of parsing the stream, creating a CMVideoFormatDescription from the SPS/PPS NALUs, and wrapping the other NALUs I extract from the stream in CMSampleBuffers.
I'm suffering from a mental block on how to handle the CMBlockBuffer and CMSampleBuffer memory for the decoder. I believe my issue is more of a lack of thorough understanding of how CF handles memory than anything else, so my question is really more about that, but I'm hoping the context is helpful.
If I create a CMBlockBuffer like this:
and add it to a CMSampleBuffer like this:
How should I handle the block buffer? Does the SampleBuffer retain the memory of the block buffer, or do I need to do something to make sure it is not deallocated?
Also, pertaining to the asynchronous decode process, is there a sensible way to know when the decoder is done with the CMSampleBuffer so I can dispose of it?
My intuition tells me the CMSampleBuffer would retain the CMBlockBuffer, and the VTDecodeSession would retain the CMSampleBuffer until it's done decoding, but this is undocumented territory I'm wandering in so looking for some direction. The results I'm getting imply my intuition might be wrong, so I need rule out memory management as an issue to keep my sanity...
xcode - 拍摄的 AVFoundation 图像很暗
在 osx 上,我使用 AVFoundation 从 USB 摄像头捕获图像,一切正常,但与实时视频相比,我得到的图像更暗。
设备捕获配置
添加实时预览视图
捕获图像的代码
从样本缓冲区数据创建一个 NSImage,我认为问题就在这里
ios - 如何在 GPUImage2 中使用 RawDataInput
CMSampleBuffer
我使用了一个名为 NextLevel 的媒体捕获库,它在每一帧上都吐出一个。我想获取这个缓冲区并通过 a 将其提供给 GPUImage2并将其传递给一些过滤器并从链末尾的rawDataInput
a 中读取它......rawDataOutput
CMSampleBuffer bytes -> rawDataInput -> someFilter -> someotherFilter -> rawDataOutput -> 为其他东西制作一个 CVPixelBuffer。
问题是,如何将 CMSampleBuffer 转换为 UInt8 数组,以便 rawDataInput 可以接收它。
我有以下代码,但它非常慢......框架一直通过链和rawDataOuput
. dataAvailableCallback
但速度慢到每秒 1 帧。我在网上找到了这段代码,不知道它在数学上做了什么,但我想它效率低下。
更新 1
我使用名为 NextLevel 的相机库来检索相机帧(CMSampleBuffer)并将它们提供给过滤器链,在本例中是通过 UInt8 字节数组的 RawDataInput。因为 NextLevel 尽可能使用亮度/色度,所以我在https://github.com/NextLevel/NextLevel/blob/master/Sources/NextLevel.swift#L1106中评论了 @rythmic fishman 评论的 5 行。但是上面的代码会中断,所以我用下面的代码替换了它。
此代码在 NextLevel 不使用亮度/色度时有效,但当使用 GPUImage RenderView 在过滤器链的末尾显示时,帧仍然非常非常慢。
更新 2
所以我决定在 GPUImage2 的 Camera.swift 中制作一个自定义的 RawDataInput.swift。因为 Camera 类以 CMSampleBuffer 格式从本机相机获取帧,所以我想.. NextLevel 抛出完全相同的缓冲区,我可以复制 GPUImage2 Camera 类的实现并删除我不需要的所有内容,只留下 1 个方法接收一个 CMSampleBuffer 并处理它。事实证明它工作得很好。除了...有一个滞后(没有丢帧,只是滞后)。我不知道瓶颈在哪里,我正在阅读处理/修改来自本机相机的 CMSampleBuffers 然后显示它们..可能会导致延迟,如这个问题中所述:如何在视频预览期间保持低延迟来自 AVFoundation?
我制作了一段关于我遇到的滞后的视频...... https://www.youtube.com/watch?v=5DQRnOTi4wk
顶角预览来自 NextLevel 的 ' previewLayer: AVCaptureVideoPreviewLayer
',过滤后的预览是位于链末端的 GPUImage2 Renderview .. 在 iPhone 6 上以 1920px 分辨率和 7 个过滤器运行。GPUImage2 Camera 类不会发生这种滞后。
这是我放在一起的自定义 RawDataInput。
我只是不明白为什么会出现这种滞后,如果它与 GPUImage2 Camera 类没有什么不同的话。NextLevel 没有对这些帧进行任何其他处理,它只是将它们传递过来,那么为什么会有延迟呢?