iOS - Как пометить аудиозапись на моем сеансе камеры? - PullRequest
0 голосов
/ 24 сентября 2018

Я пытаюсь добавить звук записи при записи видео сеанса.Я хочу помочь мне, как сделать синтаксис или где добавить мое аудиоустройство и где объединить файлы.

func setupCameraSession() {

    // setup video device input
    let videoDeviceInput: AVCaptureDeviceInput

    do {
        videoDeviceInput = try AVCaptureDeviceInput(device: currentDevice!)
    }
    catch {
        fatalError("Could not create AVCaptureDeviceInput instance with error: \(error).")
    }
    guard cameraSession.canAddInput(videoDeviceInput) else {
        fatalError()
    }
    cameraSession.addInput(videoDeviceInput)

    // setup video output
    self.videoDataOutput = AVCaptureVideoDataOutput()
    self.videoDataOutput?.videoSettings = [ kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA) ]
    let queue: DispatchQueue = DispatchQueue(label: "videocapturequeue", attributes: [])
    self.videoDataOutput?.setSampleBufferDelegate(self, queue: queue)
    self.videoDataOutput?.alwaysDiscardsLateVideoFrames = true
    if self.cameraSession.canAddOutput(videoDataOutput!) {
        self.cameraSession.addOutput(videoDataOutput!)
    }
    do {
        try self.currentDevice?.lockForConfiguration()
        self.currentDevice?.activeVideoMinFrameDuration = CMTimeMake(1, fpsValue) // 20 fps
        self.currentDevice?.unlockForConfiguration()
    } catch {
        print("could not configure a device")
        return
    }
    self.cameraSession.startRunning()
}
...