mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +00:00
Fix video writing
This commit is contained in:
parent
e263622b64
commit
2c62b6dcf3
@ -933,8 +933,7 @@ public func recommendedVideoExportConfiguration(values: MediaEditorValues, frame
|
||||
AVVideoCodecKey: AVVideoCodecType.hevc,
|
||||
AVVideoCompressionPropertiesKey: compressionProperties,
|
||||
AVVideoWidthKey: 720,
|
||||
AVVideoHeightKey: 1280,
|
||||
MediaEditorVideoExport.Configuration.FrameRateKey: frameRate
|
||||
AVVideoHeightKey: 1280
|
||||
]
|
||||
|
||||
let audioSettings: [String: Any] = [
|
||||
@ -947,6 +946,7 @@ public func recommendedVideoExportConfiguration(values: MediaEditorValues, frame
|
||||
return MediaEditorVideoExport.Configuration(
|
||||
videoSettings: videoSettings,
|
||||
audioSettings: audioSettings,
|
||||
values: values
|
||||
values: values,
|
||||
frameRate: frameRate
|
||||
)
|
||||
}
|
||||
|
||||
@ -61,7 +61,10 @@ public final class MediaEditorVideoAVAssetWriter: MediaEditorVideoExportWriter {
|
||||
}
|
||||
|
||||
var videoSettings = configuration.videoSettings
|
||||
videoSettings[AVVideoExpectedSourceFrameRateKey] = sourceFrameRate
|
||||
if var compressionSettings = videoSettings[AVVideoCompressionPropertiesKey] as? [String: Any] {
|
||||
compressionSettings[AVVideoExpectedSourceFrameRateKey] = sourceFrameRate
|
||||
videoSettings[AVVideoCompressionPropertiesKey] = compressionSettings
|
||||
}
|
||||
|
||||
let videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings)
|
||||
videoInput.expectsMediaDataInRealTime = false
|
||||
@ -175,21 +178,22 @@ public final class MediaEditorVideoExport {
|
||||
}
|
||||
|
||||
public struct Configuration {
|
||||
public static let FrameRateKey = "Telegram__FrameRate"
|
||||
|
||||
public var shouldOptimizeForNetworkUse: Bool = true
|
||||
public var videoSettings: [String: Any]
|
||||
public var audioSettings: [String: Any]
|
||||
public var values: MediaEditorValues
|
||||
public var frameRate: Float
|
||||
|
||||
public init(
|
||||
videoSettings: [String: Any],
|
||||
audioSettings: [String: Any],
|
||||
values: MediaEditorValues
|
||||
values: MediaEditorValues,
|
||||
frameRate: Float
|
||||
) {
|
||||
self.videoSettings = videoSettings
|
||||
self.audioSettings = audioSettings
|
||||
self.values = values
|
||||
self.frameRate = frameRate
|
||||
}
|
||||
|
||||
var timeRange: CMTimeRange? {
|
||||
@ -211,14 +215,6 @@ public final class MediaEditorVideoExport {
|
||||
return CGSize(width: 1920.0, height: 1080.0)
|
||||
}
|
||||
}
|
||||
|
||||
var frameRate: Float {
|
||||
if let frameRate = self.videoSettings[Configuration.FrameRateKey] as? Float {
|
||||
return frameRate
|
||||
} else {
|
||||
return 30.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user