react-native-compressor icon indicating copy to clipboard operation
react-native-compressor copied to clipboard

Compression video manual: not doing anything

Open pierroo opened this issue 3 years ago • 1 comments

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

  • [X] Android

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
      },

pierroo avatar Apr 16 '22 14:04 pierroo

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

github-actions[bot] avatar Apr 16 '22 14:04 github-actions[bot]

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

nikonhub avatar Nov 26 '22 10:11 nikonhub

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!

pierroo avatar Nov 26 '22 10:11 pierroo

@pierroo did you manage to solve the issue?

RAIERIN avatar Dec 30 '22 08:12 RAIERIN

@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.

pierroo avatar Dec 30 '22 09:12 pierroo

@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

numandev1 avatar Aug 19 '23 07:08 numandev1