Thursday, August 1, 2024
HomeiOS Developmentavfoundation - iOS AVMutableVideoComposition not distinguishing between panorama orientations

avfoundation – iOS AVMutableVideoComposition not distinguishing between panorama orientations


In my code, the person chooses a video from the digital camera roll, which I then slice up and write again to the digital camera roll utilizing AVMutableVideoComposition and AVAssetExportSession.

It’s working high quality for me when the video is in portrait, however not a lot when the video was shot in panorama. Particularly, when the video is panorama left (which I am calling when the person rotates the telephone counter clockwise) it really works high quality, however when the video is panorama proper (i.e. the person rotates the telephone clockwise) the top result’s the other way up.

Curiously, the preferredTransform and the naturalSize of the movies are at all times (1, 0, 0, 1) and 1280 x 720, whatever the perceived orientation of the video. So how may I distinguish between the totally different panorama orientations, so I might optionally rotate the video 180 levels?

Actually, the one manner I do know if the video is portrait is utilizing this submit:

func isVideoPortrait(theAsset: AVAsset) -> Bool {
    guard let videoTrack = theAsset.tracks(withMediaType: AVMediaType.video).first else {
        return false
    }
    let transformedVideoSize = videoTrack.naturalSize.making use of(videoTrack.preferredTransform)
    return abs(transformedVideoSize.width) < abs(transformedVideoSize.top)
}

There may be a variety of code, so if what I’ve shared above is just not enough, I’ll add extra about how the video consists and exported.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments