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>
This commit is contained in:
Evgeny
2026-04-30 08:37:54 +01:00
committed by GitHub
parent 26cb08ed21
commit ab2d036301
2 changed files with 5 additions and 3 deletions
@@ -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
@@ -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)
}
}