README.md 6.8 KB
Newer Older
R
Romain Vimont 已提交
1
# scrcpy
R
Romain Vimont 已提交
2

R
Romain Vimont 已提交
3 4 5
This application provides display and control of Android devices connected on
USB. It does not require any _root_ access. It works on _GNU/Linux_, _Windows_
and _Mac OS_.
R
Romain Vimont 已提交
6

R
Romain Vimont 已提交
7
![screenshot](assets/screenshot-debian-600.jpg)
R
Romain Vimont 已提交
8 9


R
Romain Vimont 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
## Requirements

The Android part requires at least API 21 (Android 5.0).

You need [adb] (recent enough so that `adb reverse` is implemented, it works
with 1.0.36). It is available in the [Android SDK platform
tools][platform-tools], on packaged in your distribution (`android-adb-tools`).

On Windows, just download the [platform-tools][platform-tools-windows] and
extract the following files to a directory accessible from your `PATH`:
 - `adb.exe`
 - `AdbWinApi.dll`
 - `AdbWinUsbApi.dll`

Make sure you [enabled adb debugging][enable-adb] on your device(s).

[adb]: https://developer.android.com/studio/command-line/adb.html
[enable-adb]: https://developer.android.com/studio/command-line/adb.html#Enabling
[platform-tools]: https://developer.android.com/studio/releases/platform-tools.html
[platform-tools-windows]: https://dl.google.com/android/repository/platform-tools-latest-windows.zip

The client requires _FFmpeg_ and _LibSDL2_.
R
Romain Vimont 已提交
32

R
Romain Vimont 已提交
33 34 35 36

## Build and install

### System-specific steps
R
Romain Vimont 已提交
37 38 39

#### Linux

R
Romain Vimont 已提交
40
Install the required packages from your package manager (here, for Debian):
R
Romain Vimont 已提交
41

R
Romain Vimont 已提交
42 43 44 45 46 47 48
    # runtime dependencies
    sudo apt install ffmpeg libsdl2-2.0.0

    # build dependencies
    sudo apt install make gcc openjdk-8-jdk pkg-config meson zip \
                     libavcodec-dev libavformat-dev libavutil-dev \
                     libsdl2-dev
R
Romain Vimont 已提交
49 50 51 52


#### Windows

R
Romain Vimont 已提交
53 54 55 56
For Windows, for simplicity, a prebuilt archive with all the dependencies
(including `adb`) is available:

 - [`scrcpy-windows-with-deps-v1.0.zip`][direct-windows-with-deps].  
57
   _(SHA-256: bc4bf32600e8548cdce490f94bed5dcba0006cdd38aff95748972e5d9877dd62)_
R
Romain Vimont 已提交
58 59 60 61

[direct-windows-with-deps]: https://github.com/Genymobile/scrcpy/releases/download/v1.0/scrcpy-windows-with-deps-v1.0.zip

_(It's just a portable version including _dll_ copied from MSYS2.)_
R
Romain Vimont 已提交
62

R
Romain Vimont 已提交
63 64
Instead, you may want to build it manually. You need [MSYS2] to build the
project. From an MSYS2 terminal, install the required packages:
R
Romain Vimont 已提交
65 66 67

[MSYS2]: http://www.msys2.org/

R
Romain Vimont 已提交
68 69 70
    # runtime dependencies
    pacman -S mingw-w64-x86_64-SDL2 \
              mingw-w64-x86_64-ffmpeg
R
Romain Vimont 已提交
71

R
Romain Vimont 已提交
72 73 74 75 76 77
    # build dependencies
    pacman -S mingw-w64-x86_64-make \
              mingw-w64-x86_64-gcc \
              mingw-w64-x86_64-pkg-config \
              mingw-w64-x86_64-meson \
              zip
R
Romain Vimont 已提交
78

R
Romain Vimont 已提交
79 80
Java (>= 7) is not available in MSYS2, so if you plan to build the server,
install it manually and make it available from the `PATH`:
R
Romain Vimont 已提交
81

R
Romain Vimont 已提交
82
    export PATH="$JAVA_HOME/bin:$PATH"
R
Romain Vimont 已提交
83 84


R
Romain Vimont 已提交
85
#### Mac OS
R
Romain Vimont 已提交
86

R
Romain Vimont 已提交
87
Use [Homebrew] to install the packages:
R
Romain Vimont 已提交
88

R
Romain Vimont 已提交
89
[Homebrew]: https://brew.sh/
R
Romain Vimont 已提交
90

R
Romain Vimont 已提交
91 92
    # runtime dependencies
    brew install sdl2 ffmpeg
R
Romain Vimont 已提交
93

R
Romain Vimont 已提交
94 95
    # build dependencies
    brew install gcc pkg-config meson zip
R
Romain Vimont 已提交
96

R
Romain Vimont 已提交
97 98
Java (>= 7) is not available in Homebrew, so if you plan to build the server,
install it manually and make it available from the `PATH`:
R
Romain Vimont 已提交
99

R
Romain Vimont 已提交
100
    export PATH="$JAVA_HOME/bin:$PATH"
R
Romain Vimont 已提交
101 102


R
Romain Vimont 已提交
103
### Common steps
R
Romain Vimont 已提交
104

R
Romain Vimont 已提交
105 106
Install the [Android SDK] (_Android Studio_), and set `ANDROID_HOME` to
its directory. For example:
R
Romain Vimont 已提交
107

R
Romain Vimont 已提交
108
[Android SDK]: https://developer.android.com/studio/index.html
R
Romain Vimont 已提交
109

R
Romain Vimont 已提交
110
    export ANDROID_HOME=~/android/sdk
R
Romain Vimont 已提交
111

R
Romain Vimont 已提交
112
Then, build `scrcpy`:
R
Romain Vimont 已提交
113

R
Romain Vimont 已提交
114 115 116
    meson x --buildtype release --strip -Db_lto=true
    cd x
    ninja
R
Romain Vimont 已提交
117

R
Romain Vimont 已提交
118
You can test it from here:
R
Romain Vimont 已提交
119

R
Romain Vimont 已提交
120
    ninja run
R
Romain Vimont 已提交
121

R
Romain Vimont 已提交
122
Or you can install it on the system:
R
Romain Vimont 已提交
123

R
Romain Vimont 已提交
124
    sudo ninja install    # without sudo on Windows
R
Romain Vimont 已提交
125

R
Romain Vimont 已提交
126
This installs two files:
127

R
Romain Vimont 已提交
128 129
 - `/usr/local/bin/scrcpy`
 - `/usr/local/share/scrcpy/scrcpy-server.jar`
R
Romain Vimont 已提交
130

R
Romain Vimont 已提交
131
Just remove them to "uninstall" the application.
R
Romain Vimont 已提交
132 133


R
Romain Vimont 已提交
134
#### Prebuilt server
R
Romain Vimont 已提交
135

R
Romain Vimont 已提交
136 137
Since the server binary, that will be pushed to the Android device, does not
depend on your system and architecture, you may want to use the prebuilt binary
R
Romain Vimont 已提交
138 139 140
instead:

 - [`scrcpy-server-v1.0.jar`][direct-scrcpy-server].  
141
   _(SHA-256: b573b06a6072476b85b6308e3ad189f2665ad5be4f8ca3a6b9ec81d64df20558)_
R
Romain Vimont 已提交
142 143

[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v1.0/scrcpy-server-v1.0.jar
R
Romain Vimont 已提交
144

R
Romain Vimont 已提交
145
In that case, the build does not require Java or the Android SDK.
R
Romain Vimont 已提交
146

R
Romain Vimont 已提交
147 148
Download the prebuilt server somewhere, and specify its path during the Meson
configuration:
R
Romain Vimont 已提交
149

R
Romain Vimont 已提交
150 151 152 153 154
    meson x --buildtype release --strip -Db_lto=true \
        -Dprebuilt_server=/path/to/scrcpy-server.jar
    cd x
    ninja
    sudo ninja install
R
Romain Vimont 已提交
155 156


R
Romain Vimont 已提交
157
## Run
R
Romain Vimont 已提交
158

R
Romain Vimont 已提交
159
_At runtime, `adb` must be accessible from your `PATH`._
R
Romain Vimont 已提交
160

R
Romain Vimont 已提交
161
If everything is ok, just plug an Android device, and execute:
162

R
Romain Vimont 已提交
163
    scrcpy
164

R
Romain Vimont 已提交
165
It accepts command-line arguments, listed by:
166

R
Romain Vimont 已提交
167
    scrcpy --help
168

R
Romain Vimont 已提交
169
For example, to decrease video bitrate to 2Mbps (default is 8Mbps):
170

R
Romain Vimont 已提交
171
    scrcpy -b 2M
172

R
Romain Vimont 已提交
173 174
To limit the video dimensions (e.g. if the device is 2540×1440, but the host
screen is smaller, or cannot decode such a high definition):
R
Romain Vimont 已提交
175

R
Romain Vimont 已提交
176
    scrcpy -m 1024
R
Romain Vimont 已提交
177

R
Romain Vimont 已提交
178
If several devices are listed in `adb devices`, you must specify the _serial_:
R
Romain Vimont 已提交
179

R
Romain Vimont 已提交
180
    scrcpy -s 0123456789abcdef
R
Romain Vimont 已提交
181

R
Romain Vimont 已提交
182 183 184 185 186 187
To run without installing:

    ./run x [options]

(where `x` is your build directory).

R
Romain Vimont 已提交
188

R
Romain Vimont 已提交
189
## Shortcuts
R
Romain Vimont 已提交
190

R
Romain Vimont 已提交
191 192 193 194 195 196 197 198 199 200 201 202
 | Action                                 |   Shortcut    |
 | -------------------------------------  | -------------:|
 | switch fullscreen mode                 | `Ctrl`+`f`    |
 | resize window to 1:1 (pixel-perfect)   | `Ctrl`+`g`    |
 | resize window to remove black borders  | `Ctrl`+`x`    |
 | click on `HOME`                        | `Ctrl`+`h`    |
 | click on `BACK`                        | `Ctrl`+`b`    |
 | click on `APP_SWITCH`                  | `Ctrl`+`m`    |
 | click on `VOLUME_UP`                   | `Ctrl`+`+`    |
 | click on `VOLUME_DOWN`                 | `Ctrl`+`-`    |
 | click on `POWER`                       | `Ctrl`+`p`    |
 | turn screen on                         | _Right-click_ |
R
Romain Vimont 已提交
203
 | paste computer clipboard to device     | `Ctrl`+`v`    |
R
Romain Vimont 已提交
204
 | enable/disable FPS counter (on stdout) | `Ctrl`+`i`    |
R
Romain Vimont 已提交
205 206


R
Romain Vimont 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
## Why _scrcpy_?

A colleague challenged me to find a name as unpronounceable as [gnirehtet].

[`strcpy`] copies a **str**ing; `scrcpy` copies a **scr**een.

[gnirehtet]: https://github.com/Genymobile/gnirehtet
[`strcpy`]: http://man7.org/linux/man-pages/man3/strcpy.3.html


## Developers

Read the [developers page].

[developers page]: DEVELOP.md


R
Romain Vimont 已提交
224
## Licence
R
Romain Vimont 已提交
225

R
Romain Vimont 已提交
226
    Copyright (C) 2018 Genymobile
R
Romain Vimont 已提交
227

R
Romain Vimont 已提交
228 229 230
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
R
Romain Vimont 已提交
231

R
Romain Vimont 已提交
232
        http://www.apache.org/licenses/LICENSE-2.0
R
Romain Vimont 已提交
233

R
Romain Vimont 已提交
234 235 236 237 238
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
239 240 241 242

## Article

- [Introducing scrcpy](https://blog.rom1v.com/2018/03/introducing-scrcpy/)