numandev1 / react-native-compressor

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

Video Compression Background Mode Expiration Limit #286

Open Hosam-hsm opened 3 months ago

Hosam-hsm commented 3 months ago

Hi, Is it possible to increase the time limit of video background compression? Currently I'm unable to compress a video of size 1GB in background due this limitation. The task automatically expires after some time while the compression was only completed 70-80% done. Also is it normal that large video (4k, 1GB) takes more than 30 seconds to compress? I am using the latest expo sdk (50.0.14) and react-native-compressor (1.8.24).

This is how I'm using the library

try {
      const Compressor = isVideo ? VideoCompressor : ImageCompressor;

      await VideoCompressor.activateBackgroundTask((data) => {
        console.log("Background Mode Expired", data);
      });

      const compressed = await Compressor.compress(
        realPath,
        {
          progressDivider: 10,
          // compressionMethod: isVideo ? "manual" : "auto",
          // ...(isVideo && { bitrate: 3000000 }),
        },
        (p) => {
          console.log(
            `File ${fileIndex + 1} Compression: ${Math.ceil(p * 100)}% complete`,
          );
        },
      );

      const compressedMetaData = await getMetaData(compressed);
      metaData = compressedMetaData;
      fileSize = metaData.size;
      path = compressed;

      await VideoCompressor.deactivateBackgroundTask();
    } catch (error) {
      throw error;
    }
github-actions[bot] commented 3 months ago

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