CodeVetter · Repo Unpack · Feature catalog
Genymobile/scrcpy
Feature surface is almost entirely CLI-driven: cli.c defines a table of ~100 long options (many with short forms) parsed via getopt_long into scrcpy_options. Major features: video mirroring (display or camera, five codecs), audio forwarding (four codecs, many sources), input control via three injection modes (SDK/UHID/AOA), screen recording to several container formats, virtual/flex displays, app launching, file push and APK install by drag-and-drop, clipboard autosync, TCP/IP wireless setup, OTG mode without adb debugging, V4L2 webcam sink, and --list-* introspection commands executed server-side.
- The full CLI surface is a static 'struct sc_option options[]' table in cli.c (~100 entries: --video-codec, --audio-source, --record, --new-display, --otg, --v4l2-sink, --tcpip, --keyboard, --mouse, --gamepad, --start-app, --list-*, etc.) fed to getopt_long by parse_args_with_getopt().
- Video codecs h264/h265/av1/vp8/vp9 and audio codecs opus/aac/flac/raw are selectable; sc_server_get_codec_name() maps them to server param strings and the demuxer maps wire codec ids to AVCodecID.
- Audio sources include output, playback, mic and mic variants (mic-unprocessed, mic-camcorder, mic-voice-recognition, mic-voice-communication, voice-call[-uplink|-downlink], voice-performance); server-side they map to AudioDirectCapture or AudioPlaybackCapture.
- Recording (--record) supports mp4, m4a, aac, mkv, mka, opus, flac and wav containers via FFmpeg muxers, with per-stream PTS rescaling and monotonic-PTS fixing.
- Input injection has three backends per device class: SDK (injectInputEvent via controller), UHID (virtual HID devices created on-device) and AOA over USB (HAVE_USB builds); the union members keyboard_sdk/uhid/aoa, mouse_sdk/uhid/aoa and gamepad_uhid/aoa are selected by --keyboard/--mouse/--gamepad modes.
- Virtual display features: --new-display creates a NewDisplayCapture, --start-app sends SC_CONTROL_MSG_TYPE_START_APP, --display-ime-policy/vd_system_decorations/vd_destroy_content/flex_display tune it; requires Android 10+.
- OTG mode (--otg) runs scrcpy_otg() which drives keyboard/mouse/gamepad over Android Open Accessory HID without adb debugging.
- V4L2 sink (--v4l2-sink, Linux-only HAVE_V4L2) registers avdevice and pipes decoded frames to a /dev/videoN device through sc_v4l2_sink with an optional v4l2_regulator buffer.
- Clipboard autosync is bidirectional: the server registers a primaryClipChanged listener sending DeviceMessage clipboard updates, and the client receiver applies them via SDL_SetClipboardText.
- File drop/APK install: sc_file_pusher runs a thread draining a request queue — 'adb push' files to push_target (default /sdcard/Download/) then sends SC_CONTROL_MSG_TYPE_SCAN_FILE so the device media-scans them, or 'adb install' for APKs.
- --tcpip automates wireless setup: get device IP via getprop, 'adb tcpip 5555', poll service.adb.tcp.port until enabled, then 'adb connect ip:port'; '--tcpip=+addr' disconnects first.
- --list-encoders/--list-displays/--list-cameras/--list-camera-sizes/--list-apps run a short-lived server invocation that prints LogUtils-built lists instead of mirroring.
- Camera mirroring (--video-source=camera, Android 12+) uses CameraCapture with facing/size/ar/fps/high-speed/torch/zoom options, and control messages CAMERA_SET_TORCH/ZOOM_IN/ZOOM_OUT are dispatched to the capture.
- Device-control extras: --turn-screen-off sends SET_DISPLAY_POWER after setup, --stay-awake, --power-off-on-close, --no-power-on, --keep-active (4s simulated user activity thread), and --kill-adb-on-close kills the whole adb server.