 
     //创建捕捉会话
     fileprivate var session :AVCaptureSession? = AVCaptureSession()
-    fileprivate var videoconnection: AVCaptureConnection?
+//    fileprivate var videoconnection: AVCaptureConnection?
+    fileprivate var videoOutput: AVCaptureOutput?
     fileprivate var previewLayer: CALayer?
     fileprivate var videoInput: AVCaptureDeviceInput?
     override func viewDidLoad() {

        //2.添加视频的输出
        let output = AVCaptureVideoDataOutput()
        output.setSampleBufferDelegate(self, queue: DispatchQueue.global())
       addInputOutput2session(input, output)
        videoconnection = output.connection(withMediaType: AVMediaTypeVideo)
        

    }
    
    fileprivate func setupAudioInputOutput(){

    //切换摄像头
    @IBAction func chageCamera(_ sender: Any) {
        guard let session = session else { return }
        //0.添加动画效果
        let rotaionAnim = CATransition()
        rotaionAnim.type = "oglFlip"
        rotaionAnim.subtype = "fromLeft"
        rotaionAnim.duration = 0.5
        view.layer.add(rotaionAnim, forKey: nil)
        
        //1.取出之前镜头的方向
        guard let videoInput = videoInput else { return}
