numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨
MIT License
852 stars 85 forks source link

Compression video manual: not doing anything #108

Closed pierroo closed 1 year ago

pierroo commented 2 years ago

Current behavior

When I compress video in 'auto', it does work pretty well. HOWEVER, since the 'auto' only gets triggered with file >16Mb, I had to go the 'manual' way. But unfortunately, WHATEVER parameters I put, I see the compress being triggered and the progress value moving up to 100%; BUT the resulting file is literally the SAME size as the original one. I really don't understand why?

Expected behavior

Platform

React Native Version

0.66.0

React Native Compressor Version

1.5.2

Reproducible Steps And Demo

Use any parameters in manual, and the result file is literally the same size as original in spite of progress showing something is happening.

await VideoCompressor.compress(path, {
        compressionMethod: 'manual',
        maxSize: 640,
        minimumFileSizeForCompress: 1,
        bitrate: 200000 // whatever I put here is not changing, like the above. Only parameter working is minimumFileSizeForCompress it seems
      },
github-actions[bot] commented 2 years ago

👋 @pierroo Thanks for opening your issue here! If you find this package useful hit the star🌟!

nikonhub commented 1 year ago

There are 3 issues on android which prevent the video compression.

1 : The bitrate variable is not passed down to native module (no bitrate switch case) => here

Fix

        case "bitrate":
          options.bitrate = (float) map.getDouble(key);
          break

2 : MaxSize is just not used as parameter => here

Fix

int maxSize = (int) options.maxSize

3 : It goes down to VideoCompressor library => here

This condition does not compress video if dimensions haven't changed. So it's not possible to just reduce bitrate without changing dimensions of the video. Unless removing this condition.

Fix => remove the condition

pierroo commented 1 year ago

That's awesome, thank you for your investigation @nikonhub ! I such with Github unfortunately; contributors @numandev1 any way you could merge the change above? That would be great!

RAIERIN commented 1 year ago

@pierroo did you manage to solve the issue?

pierroo commented 1 year ago

@RAIERIN unfortunately not, I forgot videos entirely because of this issue. I guess you might be able to patch-package the library here applying the fix from nikonhub above, although I haven't tried it myself.

numandev1 commented 1 year ago

@pierroo auto get triggered with file >16Mb but we can change it to > 0mb by adding minimumFileSizeForCompress:0 Note: in next version, i am adding minimumFileSizeForCompress:0 by default