Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to crop a video using react native

are there any library for react native to crop videos. by cropping videos I mean showing some part of the video and rejecting other parts like we crop the images. I am not talking about trimming the video because there is a difference between the word trim and crop

like image 201
Sharjeel Baig Avatar asked Dec 12 '25 02:12

Sharjeel Baig


1 Answers

Have you tried https://github.com/shahen94/react-native-video-processing?

Here's an example of how it would be used to crop:

// portrait video output 720 x 1280
const aspectRatio =  640 / 480;
const outputWidth = video.width;
const outputHeight = parseInt(outputWidth * aspectRatio);
const options = {
   cropWidth: video.width,
   cropHeight: outputHeight,
   cropOffsetX: 0,
   cropOffsetY: parseInt(Math.abs((video.height - outputHeight) / 2)),
}
ProcessingManager.crop(video.uri, options).then(data => {
   console.log('success', data)
   // use video compress for 640 x 480
   ...
}).catch(error => {
   console.log('error', error)
})
like image 66
Steve Strates Avatar answered Dec 14 '25 15:12

Steve Strates



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!