Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Preview and video stabilization do not work in any mode #240

Open
denis-severinov opened this issue Dec 24, 2020 · 1 comment
Open
Labels

Comments

@denis-severinov
Copy link

denis-severinov commented Dec 24, 2020

Preview and video stabilization do not work in any mode. I configure the session in viewDidLoad, launch the camera in viewWillApear.

Code:

        nextLevel.captureMode = .video

        nextLevel.videoConfiguration.preset = .high
        nextLevel.videoConfiguration.bitRate = 5500000
        nextLevel.videoConfiguration.maxKeyFrameInterval = 60        
        nextLevel.videoConfiguration.profileLevel = AVVideoProfileLevelH264HighAutoLevel
        nextLevel.videoConfiguration.maximumCaptureDuration = CMTimeMakeWithSeconds(maxDuration, preferredTimescale: 600)
        
        nextLevel.audioConfiguration.bitRate = 44000
        
        nextLevel.exposureMode = .continuousAutoExposure
        nextLevel.videoStabilizationMode = .cinematicExtended
        nextLevel.automaticallyConfiguresApplicationAudioSession = false
        nextLevel.focusMode = .continuousAutoFocus
internal func updateVideoOutputSettings() {
        if let videoOutput = self._videoOutput {
            if let videoConnection = videoOutput.connection(with: AVMediaType.video) {
                if videoConnection.isVideoStabilizationSupported {
                    videoConnection.preferredVideoStabilizationMode = self.videoStabilizationMode
                }
            }
        }
    }

Line videoConnection.preferredVideoStabilizationMode = self.videoStabilizationMode is unreachable because video connection doesn't exist. So set videoStabilizationMode in viewDidApear and it will work

@dstuecken
Copy link

I figured out that you need to set it after setting up and starting the AV session.

@piemonte piemonte added the bug label Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants