numandev1 / react-native-compressor

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

Video Quality lost #278

Open alihussainkabri opened 7 months ago

alihussainkabri commented 7 months ago

when I am uploading video from my react native app then it was going to reduce the quality of the video.

github-actions[bot] commented 7 months ago

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

serolgames commented 5 months ago

That's the goal of the package... If you reduce the size of your video/image a bit of the quality will be lost. if you think your video quality is too low, simply reduce the compression level It's not an issue, you can close it

alihussainkabri commented 5 months ago

How can i reduce that can you give me snippet of the code

On Tue, 21 May 2024 at 4:56 PM, serolgames @.***> wrote:

That's the goal of the package... If you reduce the size of your video/image a bit of the quality will be lost. if you think your video quality is too low, simply reduce the compression level It's not an issue, you can close it

— Reply to this email directly, view it on GitHub https://github.com/numandev1/react-native-compressor/issues/278#issuecomment-2122416134, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDLZVLTLUQI25RJSTJ5M6TZDMVN5AVCNFSM6AAAAABEXWTYN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRSGQYTMMJTGQ . You are receiving this because you were mentioned.Message ID: @.***>

serolgames commented 5 months ago

This is a code I made to use compression in percent :


const videoCompressionLevel = 40;
                const originalVideoMetada : VideoMetada = await getVideoMetaData(result.assets[0].uri) as VideoMetada;
                const targetBitrate : number = Math.round((originalVideoMetada.size) / ((originalVideoMetada.duration / 60) * 0.0075) * (1 - (videoCompressionLevel / 100)))

                const compressedVideo = await VideoCompressor.compress(
                    result.assets[0].uri,
                    {

                        progressDivider: 20,
                        maxSize: 1920,
                        bitrate: targetBitrate,
                        compressionMethod: "manual",
                        downloadProgress: (progress) => {
                            console.log('downloadProgress: ', progress);
                        },
                    },
                    (progress) => {
                        console.log('Compression Progress: ', progress);
                    }
                ); 
```  if this fits your needs, don't forget to close the issue 
AryanGupta2002 commented 5 months ago

I have tried putting different values of Bitrate but I am getting the same Output every time

srinu6 commented 3 months ago

you need to put compressionMethod: "manual". I tried the way, I got different outputs but the quality is not good any any output.