react-native-compressor 1.18.2 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -164,7 +164,9 @@ class VideoCompressor {
164
164
  return 30
165
165
  }
166
166
 
167
- return min(max(nominalFrameRate, 1), 30)
167
+ // Cap at 60 fps. 30 fps cap silently halved 60 fps recordings and
168
+ // produced visibly choppy output.
169
+ return min(max(nominalFrameRate, 1), 60)
168
170
  }
169
171
 
170
172
  func scaledDimensions(width: CGFloat, height: CGFloat, maxSize: CGFloat) -> (width: Int, height: Int) {
@@ -193,26 +195,32 @@ class VideoCompressor {
193
195
  targetHeight: Int,
194
196
  targetFrameRate: Int
195
197
  ) -> Int {
198
+ // WhatsApp-style bitrate envelope. The previous floors/ceilings were
199
+ // ~2-3x larger and produced "compressed" outputs that were still
200
+ // 20-40 MB for short clips. These bands target ~1.5 Mbps at 720p,
201
+ // matching WhatsApp's typical output size while keeping visual
202
+ // quality acceptable for chat playback. Must stay in sync with
203
+ // VideoCompressionProfile.kt on Android.
196
204
  let targetLongSide = max(targetWidth, targetHeight)
197
205
  let floor: Int
198
206
  let ceiling: Int
199
207
 
200
208
  switch targetLongSide {
201
209
  case 1920...:
202
- floor = 4_000_000
203
- ceiling = 8_000_000
210
+ floor = 2_000_000
211
+ ceiling = 3_500_000
204
212
  case 1280...1919:
205
- floor = 2_200_000
206
- ceiling = 5_000_000
213
+ floor = 1_200_000
214
+ ceiling = 2_000_000
207
215
  case 960...1279:
208
- floor = 1_600_000
209
- ceiling = 3_500_000
216
+ floor = 900_000
217
+ ceiling = 1_500_000
210
218
  case 720...959:
211
- floor = 1_200_000
212
- ceiling = 2_500_000
219
+ floor = 700_000
220
+ ceiling = 1_200_000
213
221
  default:
214
- floor = 850_000
215
- ceiling = 1_500_000
222
+ floor = 500_000
223
+ ceiling = 900_000
216
224
  }
217
225
 
218
226
  guard originalBitrate > 0 else {
@@ -336,6 +344,14 @@ class VideoCompressor {
336
344
  ]
337
345
  }
338
346
 
347
+ // Preserve source metadata (location, creation date, etc.) by forwarding
348
+ // every available metadata format to the writer.
349
+ var preservedMetadata: [AVMetadataItem] = asset.metadata
350
+ for format in asset.availableMetadataFormats {
351
+ preservedMetadata.append(contentsOf: asset.metadata(forFormat: format))
352
+ }
353
+ exporter.metadata = preservedMetadata
354
+
339
355
  compressorExports[uuid] = exporter
340
356
  exporter.export(progressHandler: { (progress) in
341
357
  let roundProgress:Int=Int((progress*100).rounded());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",