diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index dc883281fc..490b0c076c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -120,6 +120,7 @@ import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.SaveToDownloadReceiver; +import xyz.nextalone.nagram.NaConfig; import xyz.nextalone.nagram.helper.AudioEnhance; public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener { @@ -678,6 +679,8 @@ public SearchImage clone() { } }; + public final static int VIDEO_BITRATE_2160 = 28400_000; + public final static int VIDEO_BITRATE_1440 = 14000_000; public final static int VIDEO_BITRATE_1080 = 6800_000; public final static int VIDEO_BITRATE_720 = 2621_440; public final static int VIDEO_BITRATE_480 = 1000_000; @@ -5799,6 +5802,18 @@ public static int makeVideoBitrate(int originalHeight, int originalWidth, int or compressFactor = 0.6f; minCompressFactor = 0.7f; } + if (NaConfig.INSTANCE.getEnhancedVideoBitrate().Bool()) { + int size = Math.min(height, width); + if (size >= 2160) { + maxBitrate = VIDEO_BITRATE_2160; + } else if (size >= 1440) { + maxBitrate = VIDEO_BITRATE_1440; + } else if (size >= 1080) { + maxBitrate = VIDEO_BITRATE_1440; + } else if (size >= 720) { + maxBitrate = VIDEO_BITRATE_1080; + } + } int remeasuredBitrate = (int) (originalBitrate / (Math.min(originalHeight / (float) (height), originalWidth / (float) (width)))); remeasuredBitrate *= compressFactor; int minBitrate = (int) (getVideoBitrateWithFactor(minCompressFactor) / (1280f * 720f / (width * height))); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 368703ef1f..c2e2656797 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -20446,9 +20446,15 @@ private Size calculateResultVideoSize() { maxSize = 1280.0f; break; case 3: - default: maxSize = 1920.0f; break; + case 4: + maxSize = 2560.0f; + break; + case 5: + default: + maxSize = 4096.0f; + break; } float scale = originalWidth > originalHeight ? maxSize / originalWidth : maxSize / originalHeight; if (selectedCompression == compressionsCount - 1 && scale >= 1f) { @@ -20728,6 +20734,13 @@ private void updateCompressionsCount(int h, int w) { } else { compressionsCount = 1; } + if (NaConfig.INSTANCE.getEnhancedVideoBitrate().Bool()) { + if (maxSize > 2560) { + compressionsCount = 6; + } else if (maxSize > 1920) { + compressionsCount = 5; + } + } } private void updateAccessibilityOverlayVisibility() { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java index 8df6ecc793..829a82fe51 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java @@ -102,6 +102,7 @@ public class NekoExperimentalSettingsActivity extends BaseNekoXSettingsActivity private final AbstractConfigCell fakeHighPerformanceDeviceRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getFakeHighPerformanceDevice())); private final AbstractConfigCell disableEmojiDrawLimitRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getDisableEmojiDrawLimit())); private final AbstractConfigCell sendMp4DocumentAsVideoRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getSendMp4DocumentAsVideo())); + private final AbstractConfigCell enhancedVideoBitrateRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getEnhancedVideoBitrate())); private final AbstractConfigCell hideProxySponsorChannelRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideProxySponsorChannel)); private final AbstractConfigCell hideSponsoredMessageRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideSponsoredMessage)); private final AbstractConfigCell ignoreBlockedRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout"))); diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index a31479ab10..87a81b0f00 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -670,6 +670,12 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val enhancedVideoBitrate = + addConfig( + "EnhancedVideoBitrate", + ConfigItem.configTypeBool, + false + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index f4bfe65dbb..284e2ce351 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -168,4 +168,5 @@ 默认 Hls 视频质量 禁用 Bot 的打开小程序按钮 使用用户昵称作为标题 + 改善上传视频画质 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index 1eb9225009..343f2f3acf 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -169,4 +169,5 @@ Default Hls Video Quality Disable Bot Open Button Use user nickname as Title + Enhanced shared video bitrate