我一直作爲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) –