相关疑难解决方法(0)

Swift IOS 使用 AVFoundation 录制视频和音频

我能够通过在此处解决此问题来成功获取录制的视频

基本上

  1. AVCaptureFileOutputRecordingDelegate原型继承
  2. 循环访问可用设备
  3. 使用相机创建会话
  4. 开始录音
  5. 停止录音
  6. 通过实现上述原型的方法获取录制视频

但该文件不附带音频。

根据这个问题,我必须单独录制音频并使用提到的类合并视频和音频

但我不知道如何同时实现视频和音频录制。

for device in devices {
    // Make sure this particular device supports video
    if (device.hasMediaType(AVMediaTypeVideo)) {
        // Finally check the position and confirm we've got the back camera
        if(device.position == AVCaptureDevicePosition.Back) {
            captureDevice = device as? AVCaptureDevice
            if captureDevice != nil {
                print("Capture device found")

                beginSession()
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在这个循环中,只有可用的设备类型是 .Front 和 .Back

avfoundation ios swift

1
推荐指数
2
解决办法
1万
查看次数

标签 统计

avfoundation ×1

ios ×1

swift ×1