Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start failed , promise reject #316

Open
1 task done
abdulragib opened this issue Nov 12, 2024 · 1 comment
Open
1 task done

start failed , promise reject #316

abdulragib opened this issue Nov 12, 2024 · 1 comment

Comments

@abdulragib
Copy link

abdulragib commented Nov 12, 2024

Current behavior

when i try to do compression then it show unhandled promise reject , start failed, but when i restart app , compression works fine,

Expected behavior

it should be without any promise rejection

Platform

  • Android
  • iOS

i did'nt check the on ios

React Native Version

0.74.0

React Native Compressor Version

1.8.25

Reproducible Steps And Demo

dont know how to reproduce same bcz sometime it error comes , it did'nt goes until i restart the app

import {VideoMetadata} from 'react-native-video';
import {
Video as VideoCompressor,
getVideoMetaData,
} from 'react-native-compressor';

export const videoCompress = async (uri, bitrate, width) => {
const videoCompressionLevel = 80;
const originalVideoMetada: VideoMetadata = (await getVideoMetaData(
uri,
)) as VideoMetadata;

let targetBitrate: number = Math.round(
(originalVideoMetada.size /
((originalVideoMetada.duration / 60) * 0.0075)) *
(1 - videoCompressionLevel / 100),
);

// Set a maximum bitrate to prevent excessive bitrate values
const MAX_BITRATE = 1000000; // 1mbps bitrate

// Ensure that the bitrate is not higher than the maximum value
if (targetBitrate > MAX_BITRATE) {
targetBitrate = MAX_BITRATE; // Apply the cap on bitrate
}

if (bitrate < MAX_BITRATE) {
targetBitrate = bitrate;
}

console.log('targetBitrate', targetBitrate);

const compressedVideo = await VideoCompressor.compress(
uri,
{
progressDivider: 20,
maxSize: 1280,
bitrate: targetBitrate,
compressionMethod: 'manual',
},
progress => {
console.log('Compression Progress: ', progress);
},
);

return compressedVideo;
};

i did'nt figure out earlier that it was compressor error until i check sentry

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant