我一直作为2014 WWDC Video - 'Direct Access to Video Encoding and Decoding'简单提到寻找高和低如何创建一个VTCompressionSession(在迅速)。如何在swift中创建VTCompressionSession?
下面的代码工作在Objective-C:
#import <Foundation/Foundation.h>
#import <VideoToolbox/VideoToolbox.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
VTCompressionSessionRef session;
VTCompressionSessionCreate(NULL, 500, 500, kCMVideoCodecType_H264, NULL, NULL, NULL, NULL, NULL, &session);
NSLog(@"created VTCompressionSession");
}
return 0;
}
但无论怎样我都试过,我不能找到一种方法,导入VTCompressionSessionCreate
到迅速。
import Foundation
import VideoToolbox
VideoToolbox.VTCompressionSessionCreate()
println("created VTCompressionSession")
该代码例如中断:Module 'VideoToolbox' has no member named 'VTCompressionSessionCreate'
。
只需拨打VTCompressionSessionCreate
即可创建错误消息Use of unresolved identifier 'VTCompressionSessionCreate'
。
它看起来像它没有暴露在swift,因为我可以调用像VTCompressionSessionEncodeFrame
就好了。我错过了明显的东西吗?
这个例子不再是(如果它的工作)适用于OS X 10.10或iOS 8传递零中的' VTCompressionSessionCreate' outputCallback参数(第8个参数)给出错误代码-12092。 –
以上将给出类型错误。在xcode的7 /迅速2以下可能的工作: VAR会话:UnsafeMutablePointer <?VTCompressionSession> =零 设状态= VTCompressionSessionCreate(kCFAllocatorDefault,的Int32(pixelWidth)的Int32(pixelHeight),kCMVideoCodecType_H264,零,零,零/ *使用默认的* /,nil,nil,session) –