Add a toggle in the developer options to optimise the media uploads. (#3408)

This commit is contained in:
Doug
2024-10-14 14:48:59 +01:00
committed by GitHub
parent b1b2297972
commit 98a5ee5b48
18 changed files with 109 additions and 34 deletions
@@ -82,6 +82,8 @@ private struct VideoProcessingInfo {
}
struct MediaUploadingPreprocessor {
let appSettings: AppSettings
enum Constants {
static let maximumThumbnailSize = CGSize(width: 800, height: 600)
static let thumbnailCompressionQuality = 0.8
@@ -368,8 +370,9 @@ struct MediaUploadingPreprocessor {
/// - Returns: the URL for the resulting video and its media info as a `VideoProcessingResult`
private func convertVideoToMP4(_ url: URL, targetFileSize: UInt = 0) async -> Result<VideoProcessingInfo, MediaUploadingPreprocessorError> {
let asset = AVURLAsset(url: url)
let presetName = appSettings.optimizeMediaUploads ? AVAssetExportPreset640x480 : AVAssetExportPreset1920x1080
guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPreset1920x1080) else {
guard let exportSession = AVAssetExportSession(asset: asset, presetName: presetName) else {
return .failure(.failedConvertingVideo)
}