SceneKitVideoRecorder
示例
要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install
。
使用 SceneKitVideoRecorder 的应用
提交 PR 添加您的应用到这里
安装
SceneKitVideoRecorder 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'SceneKitVideoRecorder'
要安装 Swift 4 分支,请在您的 Podfile 中添加以下行
pod 'SceneKitVideoRecorder', :git => 'https://github.com/svtek/SceneKitVideoRecorder.git', :branch => 'swift4'
使用方法
将 NSMicrophoneUsageDescription
添加到 info.plist
将以下代码添加到您的视图控制器中
var recorder: SceneKitVideoRecorder?
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if recorder == nil {
var options = SceneKitVideoRecorder.Options.default
let scale = UIScreen.main.nativeScale
let sceneSize = sceneView.bounds.size
options.videoSize = CGSize(width: sceneSize.width * scale, height: sceneSize.height * scale)
recorder = try! SceneKitVideoRecorder(withARSCNView: sceneView, options: options)
}
}
@IBAction func startRecording (sender: UIButton) {
self.recorder?.startWriting().onSuccess {
print("Recording Started")
}
}
@IBAction func stopRecording (sender: UIButton) {
self.recorder?.finishWriting().onSuccess { [weak self] url in
print("Recording Finished", url)
}
}
性能提示
以下是一段 Apple 样例代码
if let camera = sceneView.pointOfView?.camera {
camera.wantsHDR = true
camera.wantsExposureAdaptation = true
camera.exposureOffset = -1
camera.minimumExposure = -1
}
代码行 camera.wantsHDR = true
和 camera.wantsExposureAdaptation = true
将导致视频录制性能大幅下降。您应将其删除或禁用以提高视频录制性能。
作者
Omer Karisman 产品经理 @ MojiLaLa |
Sahin Boydas 联合创始人 @ MojiLaLa |
---|
灵感来源于
noppefoxwolf, [email protected]
许可证
SceneKitVideoRecorder 使用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。