From fbfb6c803fa3f844f8b5c62ee96d2ebec0222dbf Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 27 Mar 2024 14:43:34 +0100 Subject: [PATCH] catch early exception in video transcoder --- .../services/AttachFileToConversationRunnable.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 1ddee27b5..5889ba333 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -99,17 +99,25 @@ public class AttachFileToConversationRunnable implements Runnable, TranscoderLis final boolean highQuality = "720".equals(getVideoCompression()); - final Future future = Transcoder.into(file.getAbsolutePath()). + final Future future; + try { + future = Transcoder.into(file.getAbsolutePath()). addDataSource(mXmppConnectionService, uri) .setVideoTrackStrategy(highQuality ? TranscoderStrategies.VIDEO_720P : TranscoderStrategies.VIDEO_360P) .setAudioTrackStrategy(highQuality ? TranscoderStrategies.AUDIO_HQ : TranscoderStrategies.AUDIO_MQ) .setListener(this) .transcode(); + } catch (final RuntimeException e) { + // transcode can already throw if there is an invalid file format or a platform bug + mXmppConnectionService.stopForcingForegroundNotification(); + processAsFile(); + return; + } try { future.get(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new AssertionError(e); - } catch (ExecutionException e) { + } catch (final ExecutionException e) { if (e.getCause() instanceof Error) { mXmppConnectionService.stopForcingForegroundNotification(); processAsFile();