简体   繁体   中英

Swift/iOS: Capture only the previous 10 seconds of a video recording

I want to constantly record a video stream using my iOS device, but given some action (Double tap screen etc.) I want to capture the 10 seconds prior to me invoking the action.

I am not sure how to do this without storing the whole video stream and then taking just the last 10 seconds of video.

Try following code may be it's work for you

   let session = AVCaptureSession()
   let movieOutput = AVCaptureMovieFileOutput()

    movieOutput.maxRecordedDuration = CMTime(seconds: 10, preferredTimescale: 1)
    if session.canAddOutput(movieOutput) {
        session.addOutput(movieOutput)
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM