问题标签 [video-toolbox]

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.

0 投票
1 回答
903 浏览

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...

0 投票
0 回答
429 浏览

ios - 如何在 iOS 上的视频工具箱上启用 H.264 单 NALU 模式?

我正在尝试在 iOS 10 (iPhone 6) 上配置视频工具箱编码器以启用 H.264 的单 NALU 模式。默认模式似乎是非交错模式,其中始终使用有效载荷类型 28 (FU-A)。在 Apple Developer API 参考中,最接近的 API 是VTCompressionSessionkVTCompressionPropertyKey_MaxH264SliceByteskVTCompressionPropertyKey_MaxFrameDelayCount

我想将kVTCompressionPropertyKey_MaxH264SliceBytes设置为小于 RTP 有效负载大小的值,并将kVTCompressionPropertyKey_MaxFrameDelayCount 设置为 1。但是,iOS 不支持这两个 API:How to set MaxH264SliceBytes property of VTCompressionSession

所以我想看看iOS是否支持H.264 Single NALU模式。如果可以,如何设置?谢谢!

0 投票
1 回答
1203 浏览

objective-c - 使用 CGDisplayStream 编码 H.264 压缩会话

我正在尝试使用我屏幕上的数据创建一个 H.264 压缩会话。我创建了一个CGDisplayStreamRef这样的实例:

以下是我目前如何设置编码功能:

我试图了解如何将屏幕上的数据转换为 a CMSampleBufferRef,以便正确调用我的编码函数。到目前为止,我还无法确定这是否可能,或者我正在尝试做的事情的正确方法。有没有人有什么建议?

编辑:我已经IOSurface转换为 a CMBlockBuffer,但还没有弄清楚如何将其转换为 a CMSampleBufferRef

编辑 2

还有一些进展:

0 投票
1 回答
396 浏览

video-toolbox - 当应用程序处于后台模式时,有没有办法让 VTDecompressionSession 解码 H264?

当应用程序处于后台模式时,有没有办法VTDecompressionSession解码 H264?

0 投票
0 回答
547 浏览

ios - 将基本流复用到传输流

我在 iOS 上使用 VideoToolbox 对来自 iPhone 相机的视频进行编码。在压缩帧的回调中,我从 AVCC 转换为附件 B。结果是传输流,如果我将其保存在 .264 文件中,我可以在 VLC 中成功播放。这是基于 Apple 的 WWDC 视频 ( https://developer.apple.com/videos/play/wwdc2014/513/ ) 和演示 ( https://github.com/manishganvir/iOS-h264Hw-Toolbox )。

现在我需要将基本流打包成传输流以启用摄像机输出的实时流:ES -> PES -> Mpeg2ts

任何人都可以指向任何库/示例代码(在 Objective-C、Swift、C/C++ 中)将基本流打包到打包的基本流,然后将 PES 复用到 TS?

0 投票
1 回答
473 浏览

ios - 如何调整 Videotoolbox 中的属性?

我现在使用 Videotoolbox 来处理 h.264 编码。

我找到了一个示例代码,它工作正常:


但是这两行,我不明白:

使用它们的正确方法是什么?

希望有人可以告诉我。

谢谢你的时间!

0 投票
2 回答
1578 浏览

objective-c - 在 VideoToolbox 中将 NSDictionary 转换为 CFDictionary

有什么区别

?

EXC_BAD_ACCESS如果我使用第二个,我会收到错误消息。为什么?

0 投票
1 回答
387 浏览

ios - VTCompressionSessionEncodeFrame:最后几秒丢失了?

我正在使用 VTCompressionSessionEncodeFrameWithOutputHandler 将像素缓冲区从相机压缩到原始 h264 流中。我正在使用 kVTEncodeFrameOptionKey_ForceKeyFrame 来确保 VTCompressionSessionEncodeFrame 的每个输出都不依赖于其他部分。此外,在会话初始化期间还有 kVTCompressionPropertyKey_AllowFrameReordering = false、kVTCompressionPropertyKey_RealTime = true 选项以及在每次 VTCompressionSessionEncodeFrame 调用后调用的 VTCompressionSessionCompleteFrames。

我还收集了由 VTCompressionSessionEncodeFrame 生成的样本,并定期将它们保存为 MP4 文件(使用 Bento4 库)。

但最终音轨总是比样本短,在 1-2 秒内输入 VTCompressionSessionEncodeFrame。经过几次尝试解决这个问题,我可以肯定,它是 VTCompressionSessionEncodeFrame 输出帧,这取决于以后要正确解码的帧 - 所以这些帧会丢失,因为它们不能用于产生轨道的“最终块” .

那么问题来了——如何强制 VTCompressionSessionEncodeFrame 产生完全独立的数据块?

0 投票
1 回答
189 浏览

objective-c - VideoToolBox 解码图像显示在 Yosemite OSX 中闪烁

我已经使用 videoToolBox 来编码和解码数据,所以一旦我们直接获得要解码的数据,我们就会传递给AVSampleBufferDisplayLayer

这是代码片段

上面的代码在 10.10 osx 中运行良好,但在 10.10 中我在屏幕上闪烁。

任何帮助都将是可观的。

0 投票
0 回答
569 浏览

cocoa - 使用 VideoToolBox 进行编码和解码

我正在编写一个使用 videotoolbox 框架使用 H264 编码 AVCaptureVideoDataOutput 的 Mac 应用程序。

回调是这样实现的:

在日志中有这些警告

GVA 警告:初始化,跳过尾随零 pps 大小 = 34 GVA 警告:AVF_Get_Standalone_PPS,跳过尾随零 pps 大小 = 35

谁能建议一种更好的解码方法以在 AVSampleBufferdisplayLayer 中显示?