From 83d48267a734e999fac0eccd93173b93019bf006 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 19 Dec 2019 11:49:50 +0100 Subject: [PATCH] Accept --max-fps before Android 10 KEY_MAX_FPS_TO_ENCODER existed privately before Android 10: --- README.md | 4 +++- app/scrcpy.1 | 2 +- app/src/cli.c | 4 ++-- .../main/java/com/genymobile/scrcpy/ScreenEncoder.java | 10 +++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4d6d29fd..10e61bca 100644 --- a/README.md +++ b/README.md @@ -137,12 +137,14 @@ scrcpy -b 2M # short version #### Limit frame rate -On devices with Android >= 10, the capture frame rate can be limited: +The capture frame rate can be limited: ```bash scrcpy --max-fps 15 ``` +This is officially supported since Android 10, but may work on earlier versions. + #### Crop The device screen may be cropped to mirror only part of the screen. diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 23b168ca..2600734b 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -43,7 +43,7 @@ Print this help. .TP .BI "\-\-max\-fps " value -Limit the framerate of screen capture (only supported on devices with Android >= 10). +Limit the framerate of screen capture (officially supported since Android 10, but may work on earlier versions). .TP .BI "\-m, \-\-max\-size " value diff --git a/app/src/cli.c b/app/src/cli.c index d9e1013a..75025563 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -42,8 +42,8 @@ scrcpy_print_usage(const char *arg0) { " Print this help.\n" "\n" " --max-fps value\n" - " Limit the frame rate of screen capture (only supported on\n" - " devices with Android >= 10).\n" + " Limit the frame rate of screen capture (officially supported\n" + " since Android 10, but may work on earlier versions).\n" "\n" " -m, --max-size value\n" " Limit both the width and height of the video to value. The\n" diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index c9a37f84..1c71eabd 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -19,6 +19,7 @@ public class ScreenEncoder implements Device.RotationListener { private static final int DEFAULT_I_FRAME_INTERVAL = 10; // seconds private static final int REPEAT_FRAME_DELAY_US = 100_000; // repeat after 100ms + private static final String KEY_MAX_FPS_TO_ENCODER = "max-fps-to-encoder"; private static final int NO_PTS = -1; @@ -150,11 +151,10 @@ public class ScreenEncoder implements Device.RotationListener { // display the very first frame, and recover from bad quality when no new frames format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, REPEAT_FRAME_DELAY_US); // µs if (maxFps > 0) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - format.setFloat(MediaFormat.KEY_MAX_FPS_TO_ENCODER, maxFps); - } else { - Ln.w("Max FPS is only supported since Android 10, the option has been ignored"); - } + // The key existed privately before Android 10: + // + // + format.setFloat(KEY_MAX_FPS_TO_ENCODER, maxFps); } return format; }