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

@ -85,8 +85,6 @@ private final class EnhanceLightnessPass: DefaultRenderPass {
renderCommandEncoder.endEncoding()
//saveTexture(self.cachedTexture!, name: "lightness", device: device)
return self.cachedTexture!
}
}

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] = [

View File

@ -351,7 +351,7 @@ private final class MediaToolsScreenComponent: Component {
guard let controller = environment.controller() as? MediaToolsScreen else {
return
}
controller.requestDismiss(animated: true)
controller.requestDismiss(reset: true, animated: true)
}
)),
environment: {},
@ -379,7 +379,7 @@ private final class MediaToolsScreenComponent: Component {
guard let controller = environment.controller() as? MediaToolsScreen else {
return
}
controller.requestDismiss(animated: true)
controller.requestDismiss(reset: false, animated: true)
}
)),
environment: {},
@ -954,10 +954,13 @@ public final class MediaToolsScreen: ViewController {
fileprivate let mediaEditor: MediaEditor
public var dismissed: () -> Void = {}
private var initialValues: MediaEditorValues
public init(context: AccountContext, mediaEditor: MediaEditor) {
self.context = context
self.mediaEditor = mediaEditor
self.initialValues = mediaEditor.values.makeCopy()
super.init(navigationBarPresentationData: nil)
self.navigationPresentation = .flatModal
@ -977,7 +980,11 @@ public final class MediaToolsScreen: ViewController {
super.displayNodeDidLoad()
}
func requestDismiss(animated: Bool) {
func requestDismiss(reset: Bool, animated: Bool) {
if reset {
self.mediaEditor.values = self.initialValues
}
self.dismissed()
self.node.animateOutToEditor(completion: {