Closed kevmmdev closed 4 years ago
okay so with zero knowledge in swift, and by desperate call. I was able to create a quick fix for this issue which honestly I don't totally understand entirely, just copied some bits of codes from the crop function and boomerang and saw there about a quick fix with videos rotating.
let composition = AVMutableComposition()
let track = composition.addMutableTrack(withMediaType: .video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
let videoOrientation = self.getVideoOrientationFromAsset(asset: asset)
if ( videoOrientation == .up ) {
var transforms: CGAffineTransform?
transforms = track?.preferredTransform
transforms = CGAffineTransform(rotationAngle: 0)
transforms = transforms?.concatenating(CGAffineTransform(rotationAngle: CGFloat(90.0 * .pi / 180)))
track?.preferredTransform = transforms!
}
else if ( videoOrientation == .down ) {
var transforms: CGAffineTransform?
transforms = track?.preferredTransform
transforms = CGAffineTransform(rotationAngle: 0)
transforms = transforms?.concatenating(CGAffineTransform(rotationAngle: CGFloat(270.0 * .pi / 180)))
track?.preferredTransform = transforms!
}
else if ( videoOrientation == .left ) {
var transforms: CGAffineTransform?
transforms = track?.preferredTransform
transforms = CGAffineTransform(rotationAngle: 0)
transforms = transforms?.concatenating(CGAffineTransform(rotationAngle: CGFloat(180.0 * .pi / 180)))
track?.preferredTransform = transforms!
}
that in RNVideoTrimmer.swift on the function trim
okay so with zero knowledge in swift, and by desperate call. I was able to create a quick fix for this issue which honestly I don't totally understand entirely, just copied some bits of codes from the crop function and boomerang and saw there about a quick fix with videos rotating.
let track = composition.addMutableTrack(withMediaType: .video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) let videoOrientation = self.getVideoOrientationFromAsset(asset: asset) if ( videoOrientation == .up || videoOrientation == .down ) { var transforms: CGAffineTransform? transforms = track?.preferredTransform transforms = CGAffineTransform(rotationAngle: 0) transforms = transforms?.concatenating(CGAffineTransform(rotationAngle: CGFloat(90.0 * .pi / 180))) track?.preferredTransform = transforms! }
that in RNVideoTrimmer.swift on the function trim
@electricfeel1979 your a life saver I spent all day trying to figure this out. Works great thanks!
okay so with zero knowledge in swift, and by desperate call. I was able to create a quick fix for this issue which honestly I don't totally understand entirely, just copied some bits of codes from the crop function and boomerang and saw there about a quick fix with videos rotating.
let track = composition.addMutableTrack(withMediaType: .video, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) let videoOrientation = self.getVideoOrientationFromAsset(asset: asset) if ( videoOrientation == .up || videoOrientation == .down ) { var transforms: CGAffineTransform? transforms = track?.preferredTransform transforms = CGAffineTransform(rotationAngle: 0) transforms = transforms?.concatenating(CGAffineTransform(rotationAngle: CGFloat(90.0 * .pi / 180))) track?.preferredTransform = transforms! }
that in RNVideoTrimmer.swift on the function trim
@electricfeel1979 your a life saver I spent all day trying to figure this out. Works great thanks!
@gmansour09 I updated the code, since the previous fix was still rotating unusual video orientations. That one fixed all of the issues. This is just a temporary fix, I have no knowledge with swift. I hope someone will be able to fix this officially.
See #299
PR is merged, releasing new version.
Just saw that this was solved, and my exact fixed was used :)
It is not worked for all type of videos..can you please suggest me any other way to solve it.
Current Behavior
When I recently updated the react native to 0.62.2 from 0.61.5, I started to have this issue with portrait videos being rotated to landscape and this only happens only on IOS. I am using the ProcessingManager.trim function.
Expected Behavior
Trim the videos but the portrait videos shout not be rotated to landscape
Your Environment