From 45ba60482054c96676628d7838bc2586ce14a866 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 10 Nov 2025 18:03:30 +0100 Subject: [PATCH 1/2] don't show weird dialog if recoding video fails --- .../securesms/video/recode/VideoRecoder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/video/recode/VideoRecoder.java b/src/main/java/org/thoughtcrime/securesms/video/recode/VideoRecoder.java index 79ce14377..a8b1cbd65 100644 --- a/src/main/java/org/thoughtcrime/securesms/video/recode/VideoRecoder.java +++ b/src/main/java/org/thoughtcrime/securesms/video/recode/VideoRecoder.java @@ -554,6 +554,8 @@ public class VideoRecoder { // the function fills out missing information and also recodes the video as needed. // return: true=video might be prepared, can be sent, false=error public static boolean prepareVideo(Context context, int chatId, DcMsg msg) { + final long MAX_BYTES = DcHelper.getInt(context, "sys.msgsize_max_recommended"); + final String TOO_BIG_FILE = "Video cannot be compressed to a reasonable size. Try a shorter video or a lower quality."; try { String inPath = msg.getFile(); Log.i(TAG, "Preparing video: " + inPath); @@ -561,9 +563,14 @@ public class VideoRecoder { // try to get information from video file VideoEditedInfo vei = getVideoEditInfoFromFile(inPath); if (vei == null) { - alert(context, String.format("Recoding failed for %s: cannot get info", inPath)); - return false; + Log.w(TAG, String.format("Recoding failed for %s: cannot get info", inPath)); + if (msg.getFilebytes() > MAX_BYTES+MAX_BYTES/4) { + alert(context, TOO_BIG_FILE); + return false; + } + return true; // if the file is small, send it without recoding } + vei.rotationValue = vei.originalRotationValue; vei.startTime = 0; vei.endTime = -1; @@ -579,7 +586,6 @@ public class VideoRecoder { // check if video bitrate is already reasonable final int MAX_KBPS = 1500000; - final long MAX_BYTES = DcHelper.getInt(context, "sys.msgsize_max_recommended"); long inBytes = new File(inPath).length(); if (inBytes > 0 && inBytes <= MAX_BYTES && vei.originalVideoBitrate <= MAX_KBPS*2 /*be tolerant as long the file size matches*/) { Log.i(TAG, String.format("recoding for %s is not needed, %d bytes and %d kbps are ok", inPath, inBytes, vei.originalVideoBitrate)); @@ -627,7 +633,7 @@ public class VideoRecoder { vei.resultVideoBitrate, vei.originalDurationMs, vei.originalAudioBytes); if (vei.estimatedBytes > MAX_BYTES+MAX_BYTES/4) { - alert(context, "Video cannot be compressed to a reasonable size. Try a shorter video or a lower quality."); + alert(context, TOO_BIG_FILE); return false; } From 5f33c8a56d2570fd4d985c99d243ca86565cc32d Mon Sep 17 00:00:00 2001 From: adbenitez Date: Mon, 10 Nov 2025 18:04:45 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610d56e83..d8de38c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * Change color of links in text messages +* Improve handling of video recoding * Tweak advanced section and wording of some advanced options ## v2.25.0