From 90d11810e3eaa2938459752ec2fdaf0b61395cca Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 21 Feb 2026 12:20:55 +0100 Subject: [PATCH] Set MediaCodec KEY_LATENCY to the minimum value The encoder must output a frame as soon as one frame is queued. Refs Refs #6238 comment PR #6670 --- .../main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java index 39ad273d..0f7e9a21 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java @@ -266,6 +266,8 @@ public class SurfaceEncoder implements AsyncProcessor { format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, REPEAT_FRAME_DELAY_US); // µs // real-time priority format.setInteger(MediaFormat.KEY_PRIORITY, 0); + // output 1 frame as soon as 1 frame is queued + format.setInteger(MediaFormat.KEY_LATENCY, 1); if (maxFps > 0) { // The key existed privately before Android 10: //