             }
         }
     }
+    
     var height: Int32 = 720 {
         didSet {
             if self.height == oldValue { return }

    }
    
    fileprivate func configureSession() {
        if session != nil {
            VTCompressionSessionInvalidate(session!)
            session = nil
        }
        let attributes: [NSString: Any] = [
            kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange),

            }
        }
    }
    
    var videoOrientation = AVCaptureVideoOrientation.portrait {
        didSet {
            if self.videoOrientation != oldValue {
                (self.width, self.height) = (self.height, self.width)
            }
        }
    }
    
    var fps: Float64 = 25 {
        didSet {
            if self.fps != oldValue {
                encoderQueue.async {
                    if let session = self.session {
                        VTSessionSetProperty(session, kVTCompressionPropertyKey_MaxKeyFrameInterval, self.fps as CFTypeRef)
                        VTSessionSetProperty(session, kVTCompressionPropertyKey_ExpectedFrameRate, self.fps as CFTypeRef)
                    }
                }
            }
        }
    }
    
    /// @see about bitrate: https://zh.wikipedia.org/wiki/比特率
    var bitrate: UInt32 = 200 * 1000 {
        didSet {
            if self.bitrate != oldValue {
                encoderQueue.async {
                    if let session = self.session {
                        VTSessionSetProperty(session, kVTCompressionPropertyKey_AverageBitRate, CFNumberCreate(nil, .sInt32Type, &self.bitrate))
                    }
                }
            }
        }
    }
    
    var keyFrameIntervalDuration: Double = 2.0 {
        didSet {
            if self.keyFrameIntervalDuration != oldValue {
                encoderQueue.async {
                    if let session = self.session {
                        VTSessionSetProperty(session, kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, CFNumberCreate(nil, .doubleType, &self.keyFrameIntervalDuration))
                    }
                }
            }
        }
    }
    
    weak var delegate: AVCEncoderDelegate?
    
    fileprivate var session: VTCompressionSession?
    fileprivate var formatDescription: CMFormatDescription?
    
    /// 编码成功回调
    fileprivate var callback: VTCompressionOutputCallback = {(
        outputCallbackRefCon:UnsafeMutableRawPointer?,
        sourceFrameRefCon:UnsafeMutableRawPointer?,
