gpt4 book ai didi

ios - VTCompressionSessionCreate 适用于 iOS 9 但不适用于 iOS 8

转载 作者:行者123 更新时间:2023-11-29 12:03:22 25 4
gpt4 key购买 nike

这些简单的代码行(应用程序中没有任何其他内容)在 iOS 9(iPhone 6 和 iPhone 4S)上运行良好,但在 iOS 8(iPhone 5 和 iPod Touch 5G)上运行不正常:

VTCompressionSessionRef videoEncoder;
OSStatus err = VTCompressionSessionCreate(NULL, 1920, 1080,
kCMVideoCodecType_H264,
NULL,
NULL,
NULL,
NULL,
(__bridge void*)self, &videoEncoder);
if (err != noErr) {
NSLog(@"Error when creating compression session : %d", (int)err);
} else {
NSLog(@"All systems go!");
}

我也尝试过使用较低的分辨率,尝试提供部分或全部可选参数,在所有情况下它都适用于 iOS 9,但在 iOS 8 上失败并出现错误 -12902 (kVTParameterErr)。很高兴知道某些参数是错误的,但是哪个参数以及为什么它在 iOS 9 上不被认为是错误的?

请注意,VTCopyVideoEncoderList 确实为我提供了一个列表,其中在所有情况下都存在 avc1 (H264) 编码器。

知道发生了什么吗?

最佳答案

答案有点晚了,但我想它可能对其他人有用。对于 iOS 8,您应该在创建压缩 session 时指定 VTCompressionOutputCallback outputCallback。来自文档:

@param  outputCallback
The callback to be called with compressed frames.
This function may be called asynchronously, on a different thread from the one that calls VTCompressionSessionEncodeFrame.
Pass NULL if and only if you will be calling VTCompressionSessionEncodeFrameWithOutputHandler for encoding frames.

反过来,VTCompressionSessionEncodeFrameWithOutputHandler 仅从 iOS 9 开始可用:

__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)

关于ios - VTCompressionSessionCreate 适用于 iOS 9 但不适用于 iOS 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com