Skip to content

Commit e030912

Browse files
authored
Merge pull request #51 from Shobbak/fix/crash-divided-by-zero
fix: measuredBitRate divided by zero crash. fixed #49
2 parents 0497f68 + aec9e45 commit e030912

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: nomi9995 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: http://buymeacoffee.com/numan.dev # Replace with a single custom sponsorship URL

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Would you like to support me?
2+
3+
<a href="https://www.buymeacoffee.com/numan.dev" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
4+
5+
---
6+
17
# react-native-compressor
28

39
<!-- Title -->

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ PODS:
293293
- glog
294294
- react-native-background-upload (6.5.0):
295295
- React
296-
- react-native-compressor (1.0.3):
296+
- react-native-compressor (1.1.0):
297297
- NextLevelSessionExporter
298298
- React-Core
299299
- react-native-create-thumbnail (1.4.1):
@@ -627,7 +627,7 @@ SPEC CHECKSUMS:
627627
React-jsinspector: 8c0517dee5e8c70cd6c3066f20213ff7ce54f176
628628
React-logger: bfddd3418dc1d45b77b822958f3e31422e2c179b
629629
react-native-background-upload: 994d4e8abbcc1d0b0cff68d950429906ed68ca67
630-
react-native-compressor: fd8cc4b27fcd00e5e784b4d8d00583075326811f
630+
react-native-compressor: 2b0f75c5e887830955b32e0ddf22ef2efe0f179e
631631
react-native-create-thumbnail: d31c84dd69fb4d60aec0ff2f49bc0de41ede7b2c
632632
react-native-document-picker: 226068006be4c52f8ef7f32d855ee025a12e9e64
633633
react-native-get-random-values: 2c4ff6b44cb71291dabe9a8ae87d3877dcf387da

example/src/Screens/Video/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default function App() {
114114
sourceVideo,
115115
{
116116
compressionMethod: 'auto',
117-
minimumFileSizeForCompress: 16,
117+
minimumFileSizeForCompress: 2,
118118
},
119119
(progress) => {
120120
if (backgroundMode) {

ios/Video/VideoCompressor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ func makeValidUri(filePath: String) -> String {
245245
let compressFactor:Float = 0.8
246246
let minCompressFactor:Float = 0.8
247247
let maxBitrate:Int = 1669000
248-
249-
var remeasuredBitrate:Int = originalBitrate / (min(originalHeight/height,originalWidth/width))
248+
let minValue:Float=min(Float(originalHeight)/Float(height),Float(originalWidth)/Float(width))
249+
var remeasuredBitrate:Int = Int(Float(originalBitrate) / minValue)
250250
remeasuredBitrate = remeasuredBitrate*Int(compressFactor)
251251
let minBitrate:Int = self.getVideoBitrateWithFactor(f: minCompressFactor) / (1280 * 720 / (width * height))
252252
if (originalBitrate < minBitrate) {

0 commit comments

Comments
 (0)