Skip to content

Commit 31fa71c

Browse files
committed
Add --ignore-video-encoder-constraints
Add an option to ignore video encoder constraints. Refs #6829 <#6829> Refs #6849 <#6849> Fixes #6848 <#6848> PR TODO
1 parent 7f29ea9 commit 31fa71c

14 files changed

Lines changed: 94 additions & 12 deletions

File tree

app/data/bash-completion/scrcpy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ _scrcpy() {
3434
-G
3535
--gamepad=
3636
-h --help
37+
--ignore-video-encoder-constraints
3738
-K
3839
--keep-active
3940
--keyboard=

app/data/zsh-completion/_scrcpy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ arguments=(
4141
'-G[Use UHID/AOA gamepad \(same as --gamepad=uhid or --gamepad=aoa, depending on OTG mode\)]'
4242
'--gamepad=[Set the gamepad input mode]:mode:(disabled uhid aoa)'
4343
{-h,--help}'[Print the help]'
44+
'--ignore-video-encoder-constraints[Do not consider video encoder capabilities]'
4445
'-K[Use UHID/AOA keyboard \(same as --keyboard=uhid or --keyboard=aoa, depending on OTG mode\)]'
4546
'--keep-active[Keep the screen on by simulating user activity]'
4647
'--keyboard=[Set the keyboard input mode]:mode:(disabled sdk uhid aoa)'

app/scrcpy.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ Also see \fB\-\-keyboard\fR and R\fB\-\-mouse\fR.
235235
.B \-h, \-\-help
236236
Print this help.
237237

238+
.TP
239+
.B \-\-ignore\-video\-encoder\-constraints
240+
Do not consider video encoder capabilities.
241+
242+
This is useful if the reported capabilities are incorrect.
243+
244+
It may help to force a value for \fB\-\-min\-size\-alignment\fR.
245+
238246
.TP
239247
.B \-K
240248
Same as \fB\-\-keyboard=uhid\fR, or \fB\-\-keyboard=aoa\fR if \fB\-\-otg\fR is set.

app/src/cli.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ enum {
109109
OPT_KEEP_ACTIVE,
110110
OPT_BACKGROUND_COLOR,
111111
OPT_RENDER_FIT,
112+
OPT_IGNORE_VIDEO_ENCODER_CONSTRAINTS,
112113
};
113114

114115
struct sc_option {
@@ -428,6 +429,13 @@ static const struct sc_option options[] = {
428429
.longopt = "help",
429430
.text = "Print this help.",
430431
},
432+
{
433+
.longopt_id = OPT_IGNORE_VIDEO_ENCODER_CONSTRAINTS,
434+
.longopt = "ignore-video-encoder-constraints",
435+
.text = "Do not consider video encoder capabilities.\n"
436+
"This is useful if the reported capabilities are incorrect.\n"
437+
"It may help to force a value for --min-size-alignment.",
438+
},
431439
{
432440
.shortopt = 'K',
433441
.text = "Same as --keyboard=uhid, or --keyboard=aoa if --otg is set.",
@@ -2917,6 +2925,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
29172925
case 'x':
29182926
opts->flex_display = true;
29192927
break;
2928+
case OPT_IGNORE_VIDEO_ENCODER_CONSTRAINTS:
2929+
opts->ignore_video_encoder_constraints = true;
2930+
break;
29202931
default:
29212932
// getopt prints the error message on stderr
29222933
return false;

app/src/options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ const struct scrcpy_options scrcpy_options_default = {
121121
.camera_torch = false,
122122
.keep_active = false,
123123
.flex_display = false,
124+
.ignore_video_encoder_constraints = false,
124125
};
125126

126127
enum sc_orientation

app/src/options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ struct scrcpy_options {
342342
bool camera_torch;
343343
bool keep_active;
344344
bool flex_display;
345+
bool ignore_video_encoder_constraints;
345346
};
346347

347348
extern const struct scrcpy_options scrcpy_options_default;

app/src/scrcpy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ scrcpy(struct scrcpy_options *options) {
406406
.vd_system_decorations = options->vd_system_decorations,
407407
.keep_active = options->keep_active,
408408
.flex_display = options->flex_display,
409+
.ignore_video_encoder_constraints =
410+
options->ignore_video_encoder_constraints,
409411
.list = options->list,
410412
};
411413

app/src/server.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ execute_server(struct sc_server *server,
420420
if (params->flex_display) {
421421
ADD_PARAM("flex_display=true");
422422
}
423+
if (params->ignore_video_encoder_constraints) {
424+
ADD_PARAM("ignore_video_encoder_constraints=true");
425+
}
423426
if (params->display_ime_policy != SC_DISPLAY_IME_POLICY_UNDEFINED) {
424427
ADD_PARAM("display_ime_policy=%s",
425428
sc_server_get_display_ime_policy_name(params->display_ime_policy));

app/src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct sc_server_params {
7575
bool vd_system_decorations;
7676
bool keep_active;
7777
bool flex_display;
78+
bool ignore_video_encoder_constraints;
7879
uint8_t list;
7980
};
8081

doc/video.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ If encoding fails, scrcpy automatically tries again with a lower definition
3131
For camera mirroring, the `--max-size` value is used to select the camera source
3232
size instead (among the available resolutions).
3333

34-
The size is rounded to a multiple of the _alignment_ required by the encoder, a
35-
power-of-2 value (1, 2, 4, 8 or 16) that the video width and height must be
36-
multiples of.
34+
The size is constrainted by the encoder capabilities, and rounded to a multiple
35+
of the _alignment_ required by the encoder, a power-of-2 value (1, 2, 4, 8 or
36+
16) that the video width and height must be multiples of.
3737

3838
The alignment can be forced to a minimum value. For instance, to force the width
3939
and height to be multiples of 8:
@@ -42,6 +42,13 @@ and height to be multiples of 8:
4242
scrcpy --min-size-alignment=8
4343
```
4444

45+
The encoder constraints can be ignored entirely using
46+
`--ignore-video-encoder-constraints`:
47+
48+
```bash
49+
scrcpy --ignore-video-encoder-constraints --min-size-alignment=8
50+
```
51+
4552

4653
## Bit rate
4754

0 commit comments

Comments
 (0)