Open lsamaria opened 4 years ago
I had to change the exporter.videoOutputConfiguration
settings and for some weird reason I had to invert the width and height. The HeightKey uses the width and WidthKey uses the height.
Outside of these issues this pod is EXCELLENT!!!
let mixComposition = AVMutableComposition()
// ...
let item = AVPlayerItem(asset: mixComposition)
let player = AVPlayer()
player.replaceCurrentItem(with: item)
let asset = player!.currentItem.asset
guard let videoTrack = asset.tracks(withMediaType: AVMediaType.video).first else { return }
exporter.videoOutputConfiguration = [
AVVideoCompressionPropertiesKey: [AVVideoAverageBitRateKey: 1100000],
AVVideoCodecKey: AVVideoCodecType.h264,
AVVideoHeightKey: videoTrack.naturalSize.width, // height uses width
AVVideoWidthKey: videoTrack.naturalSize.height // width uses height
]
thanks @lsamaria !
i appreciate the project interest. seems like a video orientation issue. will check into sometime
I solved a similar issue I had by calculating the width and height based on this:
videoTrack.naturalSize.applying(videoTrack.preferredTransform)
I have several videos that I stitch together using an AVMutableComposition(). After it's done the only way that I found to pass it to the NextLevelSessionExporter was to add it to a player and then extract the player's asset so that I can get the naturalSize. After the NextLevelSessionExporter is finished and I play the video, the video is centered in the middle of the screen.
This screenshot is the problem, the blue circle is a button and has nothing to do with it:
If I use a regular AVExportSession() the video takes up the screen like it's supposed to so there is something going wrong with NextLevelSessionExporter.