From 3a48111b5004d4cec43ad958a85834abc29a156b Mon Sep 17 00:00:00 2001 From: Miguel Nieto <39246879+miguelnietoa@users.noreply.github.com> Date: Mon, 12 Oct 2026 19:29:43 -0500 Subject: [PATCH] fix(ios): honour progressDivider for Video.compress Nitro hands JS numbers over as Double, which `as? Int` never matches, so progressDivider always fell back to 0 and progress fired once per encoded frame. Read it through NSNumber, as bitrate and maxSize already are. Fixes #425 --- ios/Video/VideoMain.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Video/VideoMain.swift b/ios/Video/VideoMain.swift index 4c6dd1a..0b8b385 100644 --- a/ios/Video/VideoMain.swift +++ b/ios/Video/VideoMain.swift @@ -64,7 +64,7 @@ class VideoCompressor { } func compress(fileUrl: String, options: [String: Any], resolve:@escaping RCTPromiseResolveBlock, reject:@escaping RCTPromiseRejectBlock) -> Void { - let progressDivider=options["progressDivider"] as? Int ?? 0 + let progressDivider=(options["progressDivider"] as? NSNumber)?.intValue ?? 0 compressVideo(url: URL(string: fileUrl)!, options:options, onProgress: { progress in EventEmitterHandler.emitVideoCompressProgress(progress, uuid: options["uuid"] as! String) @@ -266,7 +266,7 @@ class VideoCompressor { func autoCompressionHelper(url: URL, options: [String: Any], onProgress: @escaping (Float) -> Void, onCompletion: @escaping (URL) -> Void, onFailure: @escaping (Error) -> Void){ let maxSize = (options["maxSize"] as? NSNumber)?.floatValue ?? 640 let uuid:String = options["uuid"] as! String - let progressDivider=options["progressDivider"] as? Int ?? 0 + let progressDivider=(options["progressDivider"] as? NSNumber)?.intValue ?? 0 let stripAudio=options["stripAudio"] as? Bool ?? false let asset = AVAsset(url: url) @@ -289,7 +289,7 @@ class VideoCompressor { func manualCompressionHelper(url: URL, options: [String: Any], onProgress: @escaping (Float) -> Void, onCompletion: @escaping (URL) -> Void, onFailure: @escaping (Error) -> Void){ let uuid:String = options["uuid"] as! String let bitRate = (options["bitrate"] as? NSNumber)?.intValue - let progressDivider=options["progressDivider"] as? Int ?? 0 + let progressDivider=(options["progressDivider"] as? NSNumber)?.intValue ?? 0 let stripAudio=options["stripAudio"] as? Bool ?? false let asset = AVAsset(url: url) guard let track = getVideoTrack(asset: asset) else { @@ -461,7 +461,7 @@ class VideoCompressor { static func getAbsoluteVideoPath(_ videoPath: String, options: [String: Any], completionHandler: @escaping (String) -> Void) { if videoPath.hasPrefix("http://") || videoPath.hasPrefix("https://") { let uuid=options["uuid"] as? String ?? "" - let progressDivider=options["progressDivider"] as? Int ?? 0 + let progressDivider=(options["progressDivider"] as? NSNumber)?.intValue ?? 0 Downloader.downloadFileAndSaveToCache(videoPath, uuid: uuid,progressDivider:progressDivider) { downloadedPath in completionHandler(downloadedPath) }