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

R
Romain Vimont 已提交
3 4 5
This project displays screens of Android devices connected on USB, and allow to
control them using the host mouse and keyboard. 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
For Windows, for simplicity, a prebuilt package with all the dependencies
(including `adb`) is available: TODO.
R
Romain Vimont 已提交
55

R
Romain Vimont 已提交
56 57
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 已提交
58 59 60

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

R
Romain Vimont 已提交
61 62 63
    # runtime dependencies
    pacman -S mingw-w64-x86_64-SDL2 \
              mingw-w64-x86_64-ffmpeg
R
Romain Vimont 已提交
64

R
Romain Vimont 已提交
65 66 67 68 69 70
    # 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 已提交
71

R
Romain Vimont 已提交
72 73
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 已提交
74

R
Romain Vimont 已提交
75
    export PATH="$JAVA_HOME/bin:$PATH"
R
Romain Vimont 已提交
76 77


R
Romain Vimont 已提交
78
#### Mac OS
R
Romain Vimont 已提交
79

R
Romain Vimont 已提交
80
Use [Homebrew] to install the packages:
R
Romain Vimont 已提交
81

R
Romain Vimont 已提交
82
[Homebrew]: https://brew.sh/
R
Romain Vimont 已提交
83

R
Romain Vimont 已提交
84 85
    # runtime dependencies
    brew install sdl2 ffmpeg
R
Romain Vimont 已提交
86

R
Romain Vimont 已提交
87 88
    # build dependencies
    brew install gcc pkg-config meson zip
R
Romain Vimont 已提交
89

R
Romain Vimont 已提交
90 91
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 已提交
92

R
Romain Vimont 已提交
93
    export PATH="$JAVA_HOME/bin:$PATH"
R
Romain Vimont 已提交
94 95


R
Romain Vimont 已提交
96
### Common steps
R
Romain Vimont 已提交
97

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

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

R
Romain Vimont 已提交
103
    export ANDROID_HOME=~/android/sdk
R
Romain Vimont 已提交
104

R
Romain Vimont 已提交
105
Then, build `scrcpy`:
R
Romain Vimont 已提交
106

R
Romain Vimont 已提交
107 108 109
    meson x --buildtype release --strip -Db_lto=true
    cd x
    ninja
R
Romain Vimont 已提交
110

R
Romain Vimont 已提交
111
You can test it from here:
R
Romain Vimont 已提交
112

R
Romain Vimont 已提交
113
    ninja run
R
Romain Vimont 已提交
114

R
Romain Vimont 已提交
115
Or you can install it on the system:
R
Romain Vimont 已提交
116

R
Romain Vimont 已提交
117
    sudo ninja install    # without sudo on Windows
R
Romain Vimont 已提交
118

R
Romain Vimont 已提交
119
This installs two files:
120

R
Romain Vimont 已提交
121 122
 - `/usr/local/bin/scrcpy`
 - `/usr/local/share/scrcpy/scrcpy-server.jar`
R
Romain Vimont 已提交
123

R
Romain Vimont 已提交
124
Just remove them to "uninstall" the application.
R
Romain Vimont 已提交
125 126


R
Romain Vimont 已提交
127
#### Prebuilt server
R
Romain Vimont 已提交
128

R
Romain Vimont 已提交
129 130 131
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
instead: [`scrcpy-server.jar`](TODO).
R
Romain Vimont 已提交
132

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

R
Romain Vimont 已提交
135 136
Download the prebuilt server somewhere, and specify its path during the Meson
configuration:
R
Romain Vimont 已提交
137

R
Romain Vimont 已提交
138 139 140 141 142
    meson x --buildtype release --strip -Db_lto=true \
        -Dprebuilt_server=/path/to/scrcpy-server.jar
    cd x
    ninja
    sudo ninja install
R
Romain Vimont 已提交
143 144


R
Romain Vimont 已提交
145
## Run
R
Romain Vimont 已提交
146

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

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

R
Romain Vimont 已提交
151
    scrcpy
152

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

R
Romain Vimont 已提交
155
    scrcpy --help
156

R
Romain Vimont 已提交
157
For example, to increase video bitrate to 8Mbps (default is 4Mbps):
158

R
Romain Vimont 已提交
159
    scrcpy -b 8M
160

R
Romain Vimont 已提交
161 162
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 已提交
163

R
Romain Vimont 已提交
164
    scrcpy -m 1024
R
Romain Vimont 已提交
165

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

R
Romain Vimont 已提交
168
    scrcpy -s 0123456789abcdef
R
Romain Vimont 已提交
169 170


R
Romain Vimont 已提交
171
## Shortcuts
R
Romain Vimont 已提交
172

R
Romain Vimont 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185
 | 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_ |
 | enable/disable FPS counter (on stdout) | `Ctrl`+`i`    |
R
Romain Vimont 已提交
186 187


R
Romain Vimont 已提交
188
## Licence
R
Romain Vimont 已提交
189

R
Romain Vimont 已提交
190
    Copyright (C) 2018 Genymobile
R
Romain Vimont 已提交
191

R
Romain Vimont 已提交
192 193 194
    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 已提交
195

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

R
Romain Vimont 已提交
198 199 200 201 202
    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.