Switch story video export to hevc 720x1280

This commit is contained in:
Ilya Laktyushin
2023-05-17 19:19:06 +04:00
parent f72f2e3c60
commit fdf3a1705b
3 changed files with 22 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ import UIKit
import Display
import TelegramCore
import AVFoundation
import VideoToolbox
public enum EditorToolKey: Int32 {
case enhance
@@ -173,6 +174,10 @@ public final class MediaEditorValues: Codable {
try container.encode(values, forKey: .toolValues)
}
public func makeCopy() -> MediaEditorValues {
return MediaEditorValues(originalDimensions: self.originalDimensions, cropOffset: self.cropOffset, cropSize: self.cropSize, cropScale: self.cropScale, cropRotation: self.cropRotation, cropMirroring: self.cropMirroring, gradientColors: self.gradientColors, videoTrimRange: self.videoTrimRange, videoIsMuted: self.videoIsMuted, drawing: self.drawing, entities: self.entities, toolValues: self.toolValues)
}
func withUpdatedCrop(offset: CGPoint, scale: CGFloat, rotation: CGFloat, mirroring: Bool) -> MediaEditorValues {
return MediaEditorValues(originalDimensions: self.originalDimensions, cropOffset: offset, cropSize: self.cropSize, cropScale: scale, cropRotation: rotation, cropMirroring: mirroring, gradientColors: self.gradientColors, videoTrimRange: self.videoTrimRange, videoIsMuted: self.videoIsMuted, drawing: self.drawing, entities: self.entities, toolValues: self.toolValues)
}
@@ -913,14 +918,17 @@ extension CodableToolValue: Codable {
public func recommendedVideoExportConfiguration(values: MediaEditorValues) -> MediaEditorVideoExport.Configuration {
let compressionProperties: [String: Any] = [
AVVideoAverageBitRateKey: 2000000
AVVideoAverageBitRateKey: 2000000,
AVVideoProfileLevelKey: kVTProfileLevel_HEVC_Main_AutoLevel
//AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel,
//AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC
]
let videoSettings: [String: Any] = [
AVVideoCodecKey: AVVideoCodecType.h264,
AVVideoCodecKey: AVVideoCodecType.hevc,
AVVideoCompressionPropertiesKey: compressionProperties,
AVVideoWidthKey: 1080,
AVVideoHeightKey: 1920
AVVideoWidthKey: 720,
AVVideoHeightKey: 1280
]
let audioSettings: [String: Any] = [