numandev1 / react-native-compressor

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

Cannot compress videos, only on real Android devices. #315

Open DIGITALSQUAD opened 1 week ago

DIGITALSQUAD commented 1 week ago

The following code works fine on Android simulators but does not work only on real Android devices. On emulators, it starts compressing and show the Compression Progress and successfully compress videos. However, it finishes immediately on real Android devices and the result file is only 28 bytes.

The variables filePath is like file:///data/user/0/com.myapp.app/cache/rn_image_picker_lib_temp_e6b2c4f4.mp4 and result is like file:///data/user/0/com.myapp.app/cache/bad8a788-36e0-41fc-983b-a6fc340e29ff.mp4 both on emulators and real devices.

Does anyone have any ideas on fixing this issue?

async compressVideo(filePath) {
  const result = await Video.compress(
    filePath,
    { compressionMethod: "auto" },
    (progress) => {
      console.log('Compression Progress: ', progress);
    }
  )

  return RNFetchBlob.fs.readFile(result, 'base64').then(data => new Buffer(data, 'base64'))
}
github-actions[bot] commented 1 week ago

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