簡體   English   中英

使用AVFoundation暫停視頻錄制

[英]Pause Video Recording Using AVFoundation

我創建了一個自定義相機,目前為止效果很好。 我可以錄制視頻並停止錄制,沒有錯誤或錯誤。 我想添加到此相機的功能是可以暫停錄制。

經過大量的在線研究,我發現解決方案是在單擊“暫停”按鈕時實際上停止錄制,而在單擊“恢復”按鈕時開始另一個錄制。 之后,您應該將視頻合並在一起。

我不確定如何合並視頻,我在網上查看了很多內容,但找不到解決方案。

謝謝!

這是我的錄音按鈕功能

@IBAction func recordVideoButtonPressed(sender:AnyObject) {

    if self.movieFileOutput.isRecording {
        isRecording = false
        self.movieFileOutput.stopRecording()
    } else {
        isRecording = true
        self.movieFileOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = self.videoOrientation()
        self.movieFileOutput.maxRecordedDuration = self.maxRecordedDuration()
        self.movieFileOutput.startRecording(toOutputFileURL: URL(fileURLWithPath: self.videoFileLocation()), recordingDelegate: self)
    }

    self.updateRecordButtonTitle()

}

這是我的暫停按鈕功能

 func pauseVideo() {
    if isRecording {
        if isPaused == false {
            isPaused = true
            recordButton.isEnabled = false
            recordButton.backgroundColor = UIColor.wetAsphalt
            recordButton.setTitle("Paused", for: .normal)
        } else {
            isPaused = false
            recordButton.isEnabled = true
            recordButton.backgroundColor = UIColor.red
            updateRecordButtonTitle()
        }
    } else {
        return
    }
}

您可以使用AVAssetWriter編寫所有框架。 您需要使用AVCaptureVideoDataOutput從攝像機獲取幀。 在這里您可以找到精品。

或者,如果您想合並視頻,請查看教程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM