Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video orientation issue while merging. #43

Open
govind300 opened this issue May 11, 2019 · 2 comments
Open

Video orientation issue while merging. #43

govind300 opened this issue May 11, 2019 · 2 comments
Labels

Comments

@govind300
Copy link

Hello team,
Thanks for this amazing library.

While using your library I found an issue, when I am merging two landscape recorded videos (1st from back camera and 2nd from the front camera in iPhone 7) the 1st video gets wrong orientation in my case flipped upside down.

It will be really helpful if you solve this issue as soon as possible.

again thanks for your contribution to the community.

@tgeorgieva tgeorgieva added the bug label Nov 19, 2019
@flyinglionSJ
Copy link

flyinglionSJ commented Apr 29, 2020

Hi team,

While using your library, I noticed that after merging recorded video file in portrait mode from camera and audio, the video was converted and displayed in landscape mode
Please help to fix this.

Thanks!
Tony

@dsmailes
Copy link
Contributor

dsmailes commented Jun 19, 2020

In VideoGenerator.swift if you add the line commented below this will fix the orientation problem.

if let aVideoAssetTrack: AVAssetTrack = aVideoAsset.tracks(withMediaType: .video).first, let aAudioAssetTrack: AVAssetTrack = aAudioAsset.tracks(withMediaType: .audio).first {
    
    //fixes the orientation issue
    mutableCompositionVideoTrack.first?.preferredTransform = aVideoAssetTrack.preferredTransform
    
  do {
    try mutableCompositionVideoTrack.first?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: aVideoAssetTrack.timeRange.duration), of: aVideoAssetTrack, at: CMTime.zero)
    try mutableCompositionAudioTrack.first?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: aVideoAssetTrack.timeRange.duration), of: aAudioAssetTrack, at: CMTime.zero)
    
  } catch{
    print(error)
  }

  totalVideoCompositionInstruction.timeRange = CMTimeRangeMake(start: CMTime.zero,duration: aVideoAssetTrack.timeRange.duration)
}

I've submitted a pull request with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants