Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let exporter = NextLevelSessionExporter(withAsset: asset)
- exporter.outputFileType = AVFileType.mov
- let tmpURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
- .appendingPathComponent(ProcessInfo().globallyUniqueString)
- .appendingPathExtension("mov")
- exporter.outputURL = tmpURL
- let compressionDict: [String: Any] = [
- AVVideoAverageBitRateKey: NSNumber(integerLiteral: 6000000),
- AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel as String,
- ]
- if #available(iOS 11.0, *) {
- exporter.videoOutputConfiguration = [
- AVVideoCodecKey: AVVideoCodecType.hevc, // set hevc codec instead of h264
- AVVideoWidthKey: NSNumber(integerLiteral: 1920),
- AVVideoHeightKey: NSNumber(integerLiteral: 1080),
- AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
- AVVideoCompressionPropertiesKey: compressionDict
- ]
- } else {
- // Fallback on earlier versions
- }
- exporter.audioOutputConfiguration = [
- AVFormatIDKey: kAudioFormatMPEG4AAC,
- AVEncoderBitRateKey: NSNumber(integerLiteral: 128000),
- AVNumberOfChannelsKey: NSNumber(integerLiteral: 2),
- AVSampleRateKey: NSNumber(value: Float(44100))
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement