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.
- package/android/src/main/java/com/reactnativecompressor/Image/ImageCompressor.kt +41 -21
- package/android/src/main/java/com/reactnativecompressor/Video/AutoVideoCompression.kt +1 -1
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressionProfile.kt +21 -11
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/compressor/Compressor.kt +322 -78
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/CompressorUtils.kt +24 -5
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/utils/LocationExtractor.kt +397 -0
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/videoHelpers/LocationBox.kt +47 -0
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/videoHelpers/MP4Builder.kt +39 -7
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/videoHelpers/Mp4Movie.kt +7 -0
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressor/videoHelpers/OutputSurface.kt +30 -4
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.kt +24 -1
- package/ios/Video/VideoMain.swift +27 -11
- package/package.json +1 -1
|
@@ -164,7 +164,9 @@ class VideoCompressor {
|
|
|
164
164
|
return 30
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
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 =
|
|
203
|
-
ceiling =
|
|
210
|
+
floor = 2_000_000
|
|
211
|
+
ceiling = 3_500_000
|
|
204
212
|
case 1280...1919:
|
|
205
|
-
floor =
|
|
206
|
-
ceiling =
|
|
213
|
+
floor = 1_200_000
|
|
214
|
+
ceiling = 2_000_000
|
|
207
215
|
case 960...1279:
|
|
208
|
-
floor =
|
|
209
|
-
ceiling =
|
|
216
|
+
floor = 900_000
|
|
217
|
+
ceiling = 1_500_000
|
|
210
218
|
case 720...959:
|
|
211
|
-
floor =
|
|
212
|
-
ceiling =
|
|
219
|
+
floor = 700_000
|
|
220
|
+
ceiling = 1_200_000
|
|
213
221
|
default:
|
|
214
|
-
floor =
|
|
215
|
-
ceiling =
|
|
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.
|
|
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",
|