react-native-video-processing
react-native-video-processing copied to clipboard
How do i know the video orientation before trimming?
How do i know the selected video's orientation as it comes in to be trimmed? I want to know whether to load the video portrait or landscape in VideoPlayer
<VideoPlayer
rotate={true/false} // use this prop to rotate video if it captured in landscape mode
/>
Have you used this method?
ProcessingManager.getPreviewForSecond()
The images I get here are not accurate,Can you help me
I have used that function, my images are also not accurate for the selected second
我已经使用了该功能,因此我的图像在选定的秒内也不准确 What a pity, but thank you anyway
我已经使用了该功能,因此我的图像在选定的秒内也不准确 What a pity, but thank you anyway
Idk if this fit your need. I write a swift function and expose it to JS:
@objc func getVideoOrientationFromAsset(asset : AVAsset) -> UIImage.Orientation {
let videoTrack: AVAssetTrack? = asset.tracks(withMediaType: AVMediaType.video)[0]
let size = videoTrack!.naturalSize
let txf: CGAffineTransform = videoTrack!.preferredTransform
if (size.width == txf.tx && size.height == txf.ty) {
return UIImage.Orientation.left;
} else if (txf.tx == 0 && txf.ty == 0) {
return UIImage.Orientation.right;
} else if (txf.tx == 0 && txf.ty == size.width) {
return UIImage.Orientation.down;
} else {
return UIImage.Orientation.up;
}
}
Pass in the local path of the video.
Since I can't find a lib to detect the video orientation, and the react-native-video-processing does actually sometimes treat vertical/horizontal as the same.