Display and control your Android device
Rename --codec-options to --video-codec-options
Romain Vimont31555fa5309b
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpyindex 1fe79765..167f736f 100644--- a/app/data/bash-completion/scrcpy+++ b/app/data/bash-completion/scrcpy@@ -3,7 +3,6 @@ _scrcpy() {local opts="--always-on-top-b --video-bit-rate=- --codec-options=--crop=-d --select-usb--disable-screensaver@@ -55,6 +54,7 @@ _scrcpy() {-V --verbosity=-v --version--video-codec=+ --video-codec-options=-w --stay-awake--window-borderless--window-title=diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpyindex ac3ec023..29bec42d 100644--- a/app/data/zsh-completion/_scrcpy+++ b/app/data/zsh-completion/_scrcpy@@ -10,7 +10,6 @@ local argumentsarguments=('--always-on-top[Make scrcpy window always on top \(above other windows\)]'{-b,--video-bit-rate=}'[Encode the video at the given bit-rate]'- '--codec-options=[Set a list of comma-separated key\:type=value options for the device encoder]''--crop=[\[width\:height\:x\:y\] Crop the device screen on the server]'{-d,--select-usb}'[Use USB device]''--disable-screensaver[Disable screensaver while scrcpy is running]'@@ -60,6 +59,7 @@ arguments=({-V,--verbosity=}'[Set the log level]:verbosity:(verbose debug info warn error)'{-v,--version}'[Print the version of scrcpy]''--video-codec=[Select the video codec]:codec:(h264 h265 av1)'+ '--video-codec-options=[Set a list of comma-separated key\:type=value options for the device video encoder]'{-w,--stay-awake}'[Keep the device on while scrcpy is running, when the device is plugged in]''--window-borderless[Disable window decorations \(display borderless window\)]''--window-title=[Set a custom window title]'diff --git a/app/scrcpy.1 b/app/scrcpy.1index 41ce28a4..49d05a14 100644--- a/app/scrcpy.1+++ b/app/scrcpy.1@@ -25,16 +25,6 @@ Encode the video at the given bit\-rate, expressed in bits/s. Unit suffixes areDefault is 8M (8000000).-.TP-.BI "\-\-codec\-options " key\fR[:\fItype\fR]=\fIvalue\fR[,...]-Set a list of comma-separated key:type=value options for the device encoder.--The possible values for 'type' are 'int' (default), 'long', 'float' and 'string'.--The list of possible codec options is available in the Android documentation-.UR https://d.android.com/reference/android/media/MediaFormat-.UE .-.TP.BI "\-\-crop " width\fR:\fIheight\fR:\fIx\fR:\fIyCrop the device screen on the server.@@ -329,6 +319,16 @@ Select a video codec (h264, h265 or av1).Default is h264.+.TP+.BI "\-\-video\-codec\-options " key\fR[:\fItype\fR]=\fIvalue\fR[,...]+Set a list of comma-separated key:type=value options for the device video encoder.++The possible values for 'type' are 'int' (default), 'long', 'float' and 'string'.++The list of possible codec options is available in the Android documentation+.UR https://d.android.com/reference/android/media/MediaFormat+.UE .+.TP.B \-w, \-\-stay-awakeKeep the device on while scrcpy is running, when the device is plugged in.diff --git a/app/src/cli.c b/app/src/cli.cindex 57e85aa4..cb1af46e 100644--- a/app/src/cli.c+++ b/app/src/cli.c@@ -38,6 +38,7 @@ enum {OPT_RENDER_DRIVER,OPT_NO_MIPMAPS,OPT_CODEC_OPTIONS,+ OPT_VIDEO_CODEC_OPTIONS,OPT_FORCE_ADB_FORWARD,OPT_DISABLE_SCREENSAVER,OPT_SHORTCUT_MOD,@@ -127,16 +128,10 @@ static const struct sc_option options[] = {.argdesc = "value",},{+ // deprecated.longopt_id = OPT_CODEC_OPTIONS,.longopt = "codec-options",.argdesc = "key[:type]=value[,...]",- .text = "Set a list of comma-separated key:type=value options for the "- "device encoder.\n"- "The possible values for 'type' are 'int' (default), 'long', "- "'float' and 'string'.\n"- "The list of possible codec options is available in the "- "Android documentation: "- "<https://d.android.com/reference/android/media/MediaFormat>",},{.longopt_id = OPT_CROP,@@ -536,6 +531,18 @@ static const struct sc_option options[] = {.text = "Select a video codec (h264, h265 or av1).\n""Default is h264.",},+ {+ .longopt_id = OPT_VIDEO_CODEC_OPTIONS,+ .longopt = "video-codec-options",+ .argdesc = "key[:type]=value[,...]",+ .text = "Set a list of comma-separated key:type=value options for the "+ "device video encoder.\n"+ "The possible values for 'type' are 'int' (default), 'long', "+ "'float' and 'string'.\n"+ "The list of possible codec options is available in the "+ "Android documentation: "+ "<https://d.android.com/reference/android/media/MediaFormat>",+ },{.shortopt = 'w',.longopt = "stay-awake",@@ -1616,7 +1623,11 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],opts->forward_key_repeat = false;break;case OPT_CODEC_OPTIONS:- opts->codec_options = optarg;+ LOGW("--codec-options is deprecated, use --video-codec-options "+ "instead.");+ // fall through+ case OPT_VIDEO_CODEC_OPTIONS:+ opts->video_codec_options = optarg;break;case OPT_ENCODER_NAME:opts->encoder_name = optarg;diff --git a/app/src/options.c b/app/src/options.cindex a087f507..0547da1b 100644--- a/app/src/options.c+++ b/app/src/options.c@@ -7,7 +7,7 @@ const struct scrcpy_options scrcpy_options_default = {.window_title = NULL,.push_target = NULL,.render_driver = NULL,- .codec_options = NULL,+ .video_codec_options = NULL,.encoder_name = NULL,#ifdef HAVE_V4L2.v4l2_device = NULL,diff --git a/app/src/options.h b/app/src/options.hindex d22078e4..bde79687 100644--- a/app/src/options.h+++ b/app/src/options.h@@ -93,7 +93,7 @@ struct scrcpy_options {const char *window_title;const char *push_target;const char *render_driver;- const char *codec_options;+ const char *video_codec_options;const char *encoder_name;#ifdef HAVE_V4L2const char *v4l2_device;diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex b09de541..2bb5794c 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -328,7 +328,7 @@ scrcpy(struct scrcpy_options *options) {.audio = options->audio,.show_touches = options->show_touches,.stay_awake = options->stay_awake,- .codec_options = options->codec_options,+ .video_codec_options = options->video_codec_options,.encoder_name = options->encoder_name,.force_adb_forward = options->force_adb_forward,.power_off_on_close = options->power_off_on_close,diff --git a/app/src/server.c b/app/src/server.cindex 7c8fba8d..eb91b2b2 100644--- a/app/src/server.c+++ b/app/src/server.c@@ -71,7 +71,7 @@ sc_server_params_destroy(struct sc_server_params *params) {// The server stores a copy of the params provided by the userfree((char *) params->req_serial);free((char *) params->crop);- free((char *) params->codec_options);+ free((char *) params->video_codec_options);free((char *) params->encoder_name);free((char *) params->tcpip_dst);}@@ -95,7 +95,7 @@ sc_server_params_copy(struct sc_server_params *dst,COPY(req_serial);COPY(crop);- COPY(codec_options);+ COPY(video_codec_options);COPY(encoder_name);COPY(tcpip_dst);#undef COPY@@ -255,8 +255,8 @@ execute_server(struct sc_server *server,if (params->stay_awake) {ADD_PARAM("stay_awake=true");}- if (params->codec_options) {- ADD_PARAM("codec_options=%s", params->codec_options);+ if (params->video_codec_options) {+ ADD_PARAM("video_codec_options=%s", params->video_codec_options);}if (params->encoder_name) {ADD_PARAM("encoder_name=%s", params->encoder_name);diff --git a/app/src/server.h b/app/src/server.hindex d3019288..352d2cae 100644--- a/app/src/server.h+++ b/app/src/server.h@@ -27,7 +27,7 @@ struct sc_server_params {enum sc_log_level log_level;enum sc_codec video_codec;const char *crop;- const char *codec_options;+ const char *video_codec_options;const char *encoder_name;struct sc_port_range port_range;uint32_t tunnel_host;diff --git a/server/src/main/java/com/genymobile/scrcpy/Options.java b/server/src/main/java/com/genymobile/scrcpy/Options.javaindex 53257cf3..9cfb7871 100644--- a/server/src/main/java/com/genymobile/scrcpy/Options.java+++ b/server/src/main/java/com/genymobile/scrcpy/Options.java@@ -20,7 +20,7 @@ public class Options {private int displayId;private boolean showTouches;private boolean stayAwake;- private List<CodecOption> codecOptions;+ private List<CodecOption> videoCodecOptions;private String encoderName;private boolean powerOffScreenOnClose;private boolean clipboardAutosync = true;@@ -146,12 +146,12 @@ public class Options {this.stayAwake = stayAwake;}- public List<CodecOption> getCodecOptions() {- return codecOptions;+ public List<CodecOption> getVideoCodecOptions() {+ return videoCodecOptions;}- public void setCodecOptions(List<CodecOption> codecOptions) {- this.codecOptions = codecOptions;+ public void setVideoCodecOptions(List<CodecOption> videoCodecOptions) {+ this.videoCodecOptions = videoCodecOptions;}public String getEncoderName() {diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.javaindex f764804c..4ff938b4 100644--- a/server/src/main/java/com/genymobile/scrcpy/Server.java+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java@@ -61,7 +61,6 @@ public final class Server {private static void scrcpy(Options options) throws IOException, ConfigurationException {Ln.i("Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (Android " + Build.VERSION.RELEASE + ")");final Device device = new Device(options);- List<CodecOption> codecOptions = options.getCodecOptions();Thread initThread = startInitThread(options);@@ -117,8 +116,8 @@ public final class Server {Streamer videoStreamer = new Streamer(connection.getVideoFd(), options.getVideoCodec(), options.getSendCodecId(),options.getSendFrameMeta());- ScreenEncoder screenEncoder = new ScreenEncoder(device, videoStreamer, options.getVideoBitRate(), options.getMaxFps(), codecOptions,- options.getEncoderName(), options.getDownsizeOnError());+ ScreenEncoder screenEncoder = new ScreenEncoder(device, videoStreamer, options.getVideoBitRate(), options.getMaxFps(),+ options.getVideoCodecOptions(), options.getEncoderName(), options.getDownsizeOnError());try {// synchronousscreenEncoder.streamScreen();@@ -242,9 +241,9 @@ public final class Server {boolean stayAwake = Boolean.parseBoolean(value);options.setStayAwake(stayAwake);break;- case "codec_options":- List<CodecOption> codecOptions = CodecOption.parse(value);- options.setCodecOptions(codecOptions);+ case "video_codec_options":+ List<CodecOption> videoCodecOptions = CodecOption.parse(value);+ options.setVideoCodecOptions(videoCodecOptions);break;case "encoder_name":if (!value.isEmpty()) {