From ab2d0363015f28827437eba44af01aba6c80463a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 30 Apr 2026 08:37:54 +0100 Subject: [PATCH] android, desktop: reduce timeout and do not use hardward acceleration for video preview generation (#6924) Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> --- .../chat/simplex/common/platform/RecAndPlay.desktop.kt | 2 ++ .../chat/simplex/common/platform/VideoPlayer.desktop.kt | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt index 59d71a83f1..8d26f2f085 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/RecAndPlay.desktop.kt @@ -14,6 +14,8 @@ import java.util.* import kotlin.math.max internal val vlcFactory: MediaPlayerFactory by lazy { MediaPlayerFactory() } +// No hardware acceleration - more secure for previews +internal val vlcPreviewFactory: MediaPlayerFactory by lazy { MediaPlayerFactory("--avcodec-hw=none") } actual class RecorderNative: RecorderInterface { private var player: MediaPlayer? = null diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/VideoPlayer.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/VideoPlayer.desktop.kt index f88c539284..90c80d3b2a 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/VideoPlayer.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/platform/VideoPlayer.desktop.kt @@ -225,9 +225,9 @@ actual class VideoPlayer actual constructor( player.media().startPaused(uri.toFile().absolutePath) val start = System.currentTimeMillis() var snap: BufferedImage? = null - while (snap == null && start + 5000 > System.currentTimeMillis()) { + while (snap == null && start + 1500 > System.currentTimeMillis()) { snap = player.snapshots()?.get() - delay(10) + delay(50) } val orientation = player.media().info().videoTracks().firstOrNull()?.orientation() if (orientation == null) { @@ -280,7 +280,7 @@ actual class VideoPlayer actual constructor( private fun putPlayer(player: Component) = playersPool.add(player) - private fun getOrCreateHelperPlayer(): CallbackMediaPlayerComponent = helperPlayersPool.removeFirstOrNull() ?: CallbackMediaPlayerComponent(MediaPlayerSpecs.callbackMediaPlayerSpec().apply { withFactory(vlcFactory) }) + private fun getOrCreateHelperPlayer(): CallbackMediaPlayerComponent = helperPlayersPool.removeFirstOrNull() ?: CallbackMediaPlayerComponent(MediaPlayerSpecs.callbackMediaPlayerSpec().apply { withFactory(vlcPreviewFactory) }) private fun putHelperPlayer(player: CallbackMediaPlayerComponent) = helperPlayersPool.add(player) } }