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

Video Compression Background Mode Expiration Limit

Open Hosam-hsm opened this issue 1 year ago • 1 comments

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

Hosam-hsm avatar Apr 11 '24 11:04 Hosam-hsm

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

github-actions[bot] avatar Apr 11 '24 11:04 github-actions[bot]

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 12 '25 02:04 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Apr 20 '25 02:04 github-actions[bot]