This page provides a comprehensive reference for scrcpy's command-line interface, documenting all available options, arguments, and configuration flags. It explains the CLI parsing architecture, option types, and how user input is transformed into the runtime configuration stored in scrcpy_options.
For information about building scrcpy from source, see 4. Build System For details on how the parsed options are used during initialization, see 2.1. Application Core
The command-line interface processes user input through a multi-stage pipeline that converts command-line arguments into a structured configuration object. The entry point is main() which calls the parsing logic.
Title: CLI Processing Flow
| Component | Location | Purpose |
|---|---|---|
main() | app/src/main.c | Entry point, invokes CLI parser. |
scrcpy_parse_args() | app/src/cli.c1817-1818 | Main parsing function defined in cli.h and implemented in cli.c. |
options array | app/src/cli.c149-1114 | Array of sc_option structures containing metadata for every flag. |
scrcpy_options | app/src/options.h239-336 | Resulting configuration structure used by the application core. |
scrcpy_options_default | app/src/options.c5-126 | Default values for all options. |
Sources: app/src/cli.c149-1114 app/src/options.h239-336 app/src/options.c5-126
Each command-line option is defined using the sc_option structure app/src/cli.c116-126 which specifies both the option's behavior and its help documentation.
Title: Option Structure Entity Map
| Type | Characteristics | Example |
|---|---|---|
| Flag | argdesc == NULL && !optional_arg | --always-on-top app/src/cli.c150-154 |
| Optional Argument | argdesc != NULL && optional_arg | --tcpip[=ip:port] app/src/cli.c1013-1019 |
| Required Argument | argdesc != NULL && !optional_arg | --max-size=value app/src/cli.c643-647 |
Sources: app/src/cli.c116-126 app/src/cli.c149-1114
| Option | Short | Argument | Default | Description |
|---|---|---|---|---|
--video-bit-rate | -b | value | 8M | Video encoding bitrate (supports K/M suffixes) app/src/cli.c1046-1052 |
--max-size | -m | value | 0 | Limit both dimensions, preserving aspect ratio app/src/cli.c643-647 |
--max-fps | value | - | Limit capture frame rate app/src/cli.c637-641 | |
--video-codec | name | h264 | Select codec: h264, h265, av1, vp8, vp9 app/src/cli.c1036-1040 | |
--video-encoder | name | - | Specific MediaCodec encoder name app/src/cli.c1021-1027 | |
--video-source | source | display | display or camera app/src/cli.c1054-1059 | |
--crop | w:h:x:y | - | Crop on server side app/src/cli.c336-340 |
Sources: app/src/cli.c149-1114 app/src/options.h42-52
| Option | Argument | Default | Description |
|---|---|---|---|
--audio-bit-rate | value | 128K | Audio encoding bitrate app/src/cli.c163-169 |
--audio-codec | name | opus | opus, aac, flac, or raw app/src/cli.c180-185 |
--audio-source | source | output | output, playback, mic, etc. app/src/cli.c214-248 |
--audio-buffer | ms | 50 | Audio buffering delay app/src/cli.c171-178 |
--audio-dup | - | - | Duplicate audio (playback source only) app/src/cli.c199-204 |
--no-audio | - | - | Disable audio forwarding app/src/cli.c719-722 |
Sources: app/src/cli.c163-248 app/src/options.h59-72
| Option | Short | Argument | Mode | Description |
|---|---|---|---|---|
--keyboard | -K | mode | sc_keyboard_input_mode | disabled, sdk, uhid, aoa app/src/cli.c484-493 |
--mouse | -M | mode | sc_mouse_input_mode | disabled, sdk, uhid, aoa app/src/cli.c664-673 |
--gamepad | -G | mode | sc_gamepad_input_mode | disabled, uhid, aoa app/src/cli.c455-464 |
--mouse-bind | bindings | - | Configure secondary click bindings app/src/cli.c675-686 | |
--otg | - | - | OTG mode (physical HID simulation) app/src/cli.c782-785 |
Sources: app/src/cli.c455-785 app/src/options.h155-178
The CLI parser converts command-line arguments into a structured configuration through a multi-step process using getopt_long().
Title: Option Parsing Logic
| Function | Source | Purpose |
|---|---|---|
sc_str_parse_integer() | app/src/util/str.h | Parse basic numeric arguments. |
sc_parse_shortcut_mods() | app/src/cli.c1223-1261 | Parses comma-separated modifiers (lctrl, lalt, etc.). |
parse_orientation() | app/src/cli.c1169-1221 | Parses orientation strings (90, flip180, @90). |
Sources: app/src/cli.c1169-1261 app/src/cli.c1817-2108
scrcpy uses specific exit codes to indicate different termination conditions.
| Code | Meaning |
|---|---|
0 | Normal termination. |
1 | Initial connection or parsing failed. |
2 | Device disconnected during session. |
Sources: app/scrcpy.1671-675 (Note: Reference based on manual synopsis; actual exit logic resides in main.c).
The modifier key (MOD) defaults to LAlt or LSuper, configurable via --shortcut-mod app/src/cli.c879-889
| Action | Shortcut |
|---|---|
| Quit | MOD+q |
| Fullscreen | MOD+f |
| HOME | MOD+h |
| BACK | MOD+b |
| Turn screen off | MOD+o |
Sources: doc/shortcuts.md24-65 app/scrcpy.1677-817
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.