numandev1 / react-native-compressor

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

Video is not resizing #65

Closed unoegohh closed 2 years ago

unoegohh commented 2 years ago

Hi! I am having troubles with video compression

"react-native-compressor": "1.2.0"
"react-native": "0.66.1"

Video.compress(file.path, {
        // compressionMethod: 'manual',
        //minimumFileSizeForCompress: 10,
        maxSize: 100,
      })
        .then(res => {...})
        .catch(console.log);

original file original file is 42mb 1080 × 1920 30 sec compressed always 3.2 mb 360 × 568

i need to do something to make video 600x1000 i have tried all params from doc but nothing changes( mb i am doing something wrong and i tried different video

numandev1 commented 2 years ago

@unoegohh let me see it

numandev1 commented 2 years ago

@unoegohh are you want manual compression or auto compression-like WhatsApp?

numandev1 commented 2 years ago

@unoegohh if I use maxSize: 1000 then I am getting 562x1000 resolution of the video which you have attached

const dstUrl = await Video.compress(
      sourceVideo,
      {
        compressionMethod: 'auto',
        minimumFileSizeForCompress: 5,
        maxSize: 1000,
      },
      (progress) => {
        if (backgroundMode) {
          console.log('Compression Progress: ', progress);
        } else {
          setCompressingProgress(progress);
        }
      }
    );
unoegohh commented 2 years ago

Hmm it is strange cause if i use

import {Video as VideoCompressor} from 'react-native-compressor';

VideoCompressor.compress(file.path, {
        compressionMethod: 'auto',
        minimumFileSizeForCompress: 5,
        maxSize: 1000,
      })
        .then(res => {
          console.log('video', res);
        })
        .catch(console.log);

and then i get

video1 file:///Users/unoegohh/Library/Developer/CoreSimulator/Devices/C856B11B-463E-48F6-9396-5F4E0838CDC2/data/Containers/Data/Application/60489947-00AB-49D1-A5F0-E72164EDD6D5/tmp/react-native-image-crop-picker/F6B9FBB8-4C2A-4882-ABBC-A3E9BFE8A0C7.mp4

and it is still get 320x564 video

file

UPD - i got my error) i was using ImagePicker.openPicker before compression and it returned already compressed video )) ty! as always i need to find error on my side first then write an issue)

numandev1 commented 2 years ago

@unoegohh yes react-native-image-crop-picker =>. openPicker is compressing video by reducing video height and width. can you put your video file into tmp directory and add a path directly to test VideoCompressor.compress("file:///...../tmp/filename.mp4"

numandev1 commented 2 years ago

I think it is already fixed. feel free to reopen if you see this problem again. thanks.