fix: video may in portrait mode issue
This commit is contained in:
parent
1e71f0c147
commit
81bc8eb662
|
@ -46,6 +46,7 @@ public struct AttachmentView: View {
|
||||||
}()
|
}()
|
||||||
Spacer()
|
Spacer()
|
||||||
TextField(placeholder, text: $viewModel.caption)
|
TextField(placeholder, text: $viewModel.caption)
|
||||||
|
.lineLimit(1)
|
||||||
.textFieldStyle(.plain)
|
.textFieldStyle(.plain)
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.placeholder(placeholder, when: viewModel.caption.isEmpty)
|
.placeholder(placeholder, when: viewModel.caption.isEmpty)
|
||||||
|
@ -196,6 +197,7 @@ extension View {
|
||||||
placeholder(when: shouldShow, alignment: alignment) {
|
placeholder(when: shouldShow, alignment: alignment) {
|
||||||
Text(text)
|
Text(text)
|
||||||
.foregroundColor(.white.opacity(0.7))
|
.foregroundColor(.white.opacity(0.7))
|
||||||
|
.lineLimit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,15 @@ extension AttachmentViewModel {
|
||||||
let exporter = NextLevelSessionExporter(withAsset: urlAsset)
|
let exporter = NextLevelSessionExporter(withAsset: urlAsset)
|
||||||
exporter.outputFileType = .mp4
|
exporter.outputFileType = .mp4
|
||||||
|
|
||||||
|
var isLandscape: Bool = {
|
||||||
|
guard let track = urlAsset.tracks(withMediaType: .video).first else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
let size = track.naturalSize.applying(track.preferredTransform)
|
||||||
|
return abs(size.width) >= abs(size.height)
|
||||||
|
}()
|
||||||
|
|
||||||
let outputURL = try FileManager.default.createTemporaryFileURL(
|
let outputURL = try FileManager.default.createTemporaryFileURL(
|
||||||
filename: UUID().uuidString,
|
filename: UUID().uuidString,
|
||||||
pathExtension: url.pathExtension
|
pathExtension: url.pathExtension
|
||||||
|
@ -30,8 +39,8 @@ extension AttachmentViewModel {
|
||||||
]
|
]
|
||||||
exporter.videoOutputConfiguration = [
|
exporter.videoOutputConfiguration = [
|
||||||
AVVideoCodecKey: AVVideoCodecType.h264,
|
AVVideoCodecKey: AVVideoCodecType.h264,
|
||||||
AVVideoWidthKey: NSNumber(integerLiteral: 1280),
|
AVVideoWidthKey: NSNumber(integerLiteral: isLandscape ? 1280 : 720),
|
||||||
AVVideoHeightKey: NSNumber(integerLiteral: 720),
|
AVVideoHeightKey: NSNumber(integerLiteral: isLandscape ? 720 : 1280),
|
||||||
AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
|
AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
|
||||||
AVVideoCompressionPropertiesKey: compressionDict
|
AVVideoCompressionPropertiesKey: compressionDict
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue