Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust 16mb minimum compression size for react-native-compressor@0.5.6 #57

Closed
emmbyiringiro opened this issue Dec 14, 2021 · 15 comments
Closed

Comments

@emmbyiringiro
Copy link

Some developers start to use this package within the expo. Unfortunately, Expo still uses an old version of React Native up to React Native 0.64.3.

Can you remove this condition https://github.com/Shobbak/react-native-compressor/blob/dd5c106522461005acd89d6f679c0ef2f96fdd74/ios/Video/VideoCompressor.swift#L205

and old version users can benefit from that patch.

@xuanhieupd
Copy link

+1

@numandev1
Copy link
Owner

@emmbyiringiro @xuanhieupd today I am busy with office work. hope I will add this tomorrow. thanks

@emmbyiringiro
Copy link
Author

Start from Expo SDK 42, the Expo team release a new service that makes the Expo app support a native module.

Expo community has no built-i media compression package. This package is the one that is a great candidate as It has an easy setup and API to work with.

I expect many Expo users to adopt this.

I wish I can help more unfortunately I don't have a background in native development.

You can read more about Expo native build here

https://docs.expo.dev/build/setup/

@numandev1
Copy link
Owner

@emmbyiringiro @xuanhieupd can you check 0.5.8

yarn add react-native-compressor@0.5.8

@emmbyiringiro
Copy link
Author

Thanks for the patch. I have another issue or I'm doing wrong something.

By default, the video size for compression is 640. When I record video with camera on android, the camera record video with width:480 and height:640 dimensions.

I was expecting this video to be compressed on to default of 640. Unfortunately, the app crash and I need to lower video compression to either 480 or 360.

I guess that the logic should check if the size is less than or equal so provide compression size.

I

@numandev1
Copy link
Owner

numandev1 commented Dec 16, 2021

@emmbyiringiro can you confirm, in 0.5.8 version minimumFileSizeForCompress is working or not? so i can write this version in docs

@numandev1
Copy link
Owner

@emmbyiringiro can you send me the video, so I can check that video on my side?

@emmbyiringiro
Copy link
Author

I investigate the issue and I found that all videos you want to compress must have a video size great than maxSize otherwise it will crash.

For example, if you have a video like this https://sample-videos.com/video123/mp4/360/big_buck_bunny_360p_1mb.mp4 which has width 640 and height 360 and you set maxSize to 640 this will crash.

Even if video size 640 is equal maxSize. The device cameras sometimes record large video sizes which require be optimized.

In this situation, both video size and maxSize are equal but the app crashes.

@emmbyiringiro
Copy link
Author

@emmbyiringiro can you confirm, in 0.5.8 version minimumFileSizeForCompress is working or not? so i can write this version in docs

I installed but it crashed with Native module not found error.

I'm using Expo SDK 42 which uses React Native 0.63 .

You can read more about this Expo Native module integration
https://blog.expo.dev/introducing-custom-development-clients-5a2c79a9ddf8

@emmbyiringiro
Copy link
Author

@emmbyiringiro can you confirm, in 0.5.8 version minimumFileSizeForCompress is working or not? so i can write this version in docs

I installed but it crashed with Native module not found error.

I'm using Expo SDK 42 which uses React Native 0.63 .

You can read more about this Expo Native module integration https://blog.expo.dev/introducing-custom-development-clients-5a2c79a9ddf8

This issue happen on android

@numandev1
Copy link
Owner

numandev1 commented Dec 17, 2021

@emmbyiringiro can you check 0.5.9 version. I have added support for the expo. you can read docs

yarn add react-native-compressor@0.5.9

Add the Compressor plugin to your Expo config (app.json, app.config.json or app.config.js):

{
  "name": "my app",
  "plugins": ["react-native-compressor"]
}

@numandev1
Copy link
Owner

numandev1 commented Dec 17, 2021

I investigate the issue and I found that all videos you want to compress must have a video size great than maxSize otherwise it will crash.

For example, if you have a video like this https://sample-videos.com/video123/mp4/360/big_buck_bunny_360p_1mb.mp4 which has width 640 and height 360 and you set maxSize to 640 this will crash.

Even if video size 640 is equal maxSize. The device cameras sometimes record large video sizes which require be optimized.

In this situation, both video size and maxSize are equal but the app crashes.

i will investigate this tonight

@emmbyiringiro
Copy link
Author

@emmbyiringiro can you check 0.5.9 version. I have added support for the expo. you can read docs

yarn add react-native-compressor@0.5.9

Add the Compressor plugin to your Expo config (app.json, app.config.json or app.config.js):

{
  "name": "my app",
  "plugins": ["react-native-compressor"]
}

Have tested this package with Expo 42. I tried and result in this error.

[TypeError: null is not an object (evaluating 'NativeVideoCompressor.compress')

It seems that EXPO SDK 42 does not register native module

@numandev1
Copy link
Owner

@emmbyiringiro after the above steps, can you run these three commands and test them?

expo prebuild

eas build

yarn ios

@numandev1
Copy link
Owner

@emmbyiringiro closing this because I have fixed it and released the 0.5.9 version. you can open another issue for the expo if you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants