                 averageBitrate = bps
             }
         }
-        
+
         var outputURL = documentDirectory.appendingPathComponent("output")
         do {
             try manager.createDirectory(at: outputURL, withIntermediateDirectories: true, attributes: nil)

                }

            case .failed:
                callback( ["Failed: \(exportSession.error?.localizedDescription)", NSNull()] )
                
            case .cancelled:
                callback( ["Cancelled: \(exportSession.error?.localizedDescription)", NSNull()] )
                
            default: break
            }
        }
    }

    @objc func compress(_ source: String, options: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
        
        var width = options.object(forKey: "width") as? Float
        var height = options.object(forKey: "height") as? Float
        let bitrateMultiplier = options.object(forKey: "bitrateMultiplier") as? Float ?? 1
        let saveToCameraRoll = options.object(forKey: "saveToCameraRoll") as? Bool ?? false
        let minimumBitrate = options.object(forKey: "minimumBitrate") as? Float
        
        let manager = FileManager.default
        guard let documentDirectory = try? manager.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
            else {
                callback(["Error creating FileManager", NSNull()])
                return
        }
        
        let sourceURL = getSourceURL(source: source)
        let asset = AVAsset(url: sourceURL as URL)
        
        guard let videoTrack = asset.tracks(withMediaType: AVMediaTypeVideo).first else  {
            callback(["Error getting track info", NSNull()])
            return
        }
        
        let naturalSize = videoTrack.naturalSize.applying(videoTrack.preferredTransform)
        let bps = videoTrack.estimatedDataRate
        width = width ?? Float(abs(naturalSize.width))

                    UISaveVideoAtPathToSavedPhotosAlbum(outputURL.relativePath, self, nil, nil)
                }
            case .failed:
                callback( ["Failed: \(compressionEncoder!.error)", NSNull()] )

            case .cancelled:
                callback( ["Cancelled: \(compressionEncoder!.error)", NSNull()] )

            default: break
            }
        })
