|
1 |
| -# ScrCpy |
| 1 | +# scrcpy |
2 | 2 |
|
3 |
| -This project displays screens of Android devices plugged on USB in live. |
| 3 | +This project displays screens of Android devices connected on USB, and allow to |
| 4 | +control them using the host mouse and keyboard. It does not require any _root_ |
| 5 | +access. It works on _GNU/Linux_, _Windows_ and _Mac OS_. |
4 | 6 |
|
| 7 | + |
5 | 8 |
|
6 |
| -## Run |
7 | 9 |
|
8 |
| -### Runtime requirements |
| 10 | +## Requirements |
| 11 | + |
| 12 | +The Android part requires at least API 21 (Android 5.0). |
| 13 | + |
| 14 | +You need [adb] (recent enough so that `adb reverse` is implemented, it works |
| 15 | +with 1.0.36). It is available in the [Android SDK platform |
| 16 | +tools][platform-tools], on packaged in your distribution (`android-adb-tools`). |
| 17 | + |
| 18 | +On Windows, just download the [platform-tools][platform-tools-windows] and |
| 19 | +extract the following files to a directory accessible from your `PATH`: |
| 20 | + - `adb.exe` |
| 21 | + - `AdbWinApi.dll` |
| 22 | + - `AdbWinUsbApi.dll` |
| 23 | + |
| 24 | +Make sure you [enabled adb debugging][enable-adb] on your device(s). |
| 25 | + |
| 26 | +[adb]: https://developer.android.com/studio/command-line/adb.html |
| 27 | +[enable-adb]: https://developer.android.com/studio/command-line/adb.html#Enabling |
| 28 | +[platform-tools]: https://developer.android.com/studio/releases/platform-tools.html |
| 29 | +[platform-tools-windows]: https://dl.google.com/android/repository/platform-tools-latest-windows.zip |
| 30 | + |
| 31 | +The client requires _FFmpeg_ and _LibSDL2_. |
9 | 32 |
|
10 |
| -This projects requires _FFmpeg_, _LibSDL2_ and _LibSDL2-net_. |
| 33 | + |
| 34 | +## Build and install |
| 35 | + |
| 36 | +### System-specific steps |
11 | 37 |
|
12 | 38 | #### Linux
|
13 | 39 |
|
14 |
| -Install the packages from your package manager. For example, on Debian: |
| 40 | +Install the required packages from your package manager (here, for Debian): |
15 | 41 |
|
16 |
| - sudo apt install ffmpeg libsdl2-2.0.0 libsdl2-net-2.0.0 |
| 42 | + # runtime dependencies |
| 43 | + sudo apt install ffmpeg libsdl2-2.0.0 |
| 44 | + |
| 45 | + # build dependencies |
| 46 | + sudo apt install make gcc openjdk-8-jdk pkg-config meson zip \ |
| 47 | + libavcodec-dev libavformat-dev libavutil-dev \ |
| 48 | + libsdl2-dev |
17 | 49 |
|
18 | 50 |
|
19 | 51 | #### Windows
|
20 | 52 |
|
21 |
| -From [MSYS2]: |
| 53 | +For Windows, for simplicity, a prebuilt package with all the dependencies |
| 54 | +(including `adb`) is available: TODO. |
22 | 55 |
|
23 |
| - pacman -S mingw-w64-x86_64-SDL2 |
24 |
| - pacman -S mingw-w64-x86_64-SDL2_net |
25 |
| - pacman -S mingw-w64-x86_64-ffmpeg |
| 56 | +Instead, you may want to build it manually. You need [MSYS2] to build the |
| 57 | +project. From an MSYS2 terminal, install the required packages: |
26 | 58 |
|
27 | 59 | [MSYS2]: http://www.msys2.org/
|
28 | 60 |
|
| 61 | + # runtime dependencies |
| 62 | + pacman -S mingw-w64-x86_64-SDL2 \ |
| 63 | + mingw-w64-x86_64-ffmpeg |
29 | 64 |
|
30 |
| -#### MacOS |
| 65 | + # build dependencies |
| 66 | + pacman -S mingw-w64-x86_64-make \ |
| 67 | + mingw-w64-x86_64-gcc \ |
| 68 | + mingw-w64-x86_64-pkg-config \ |
| 69 | + mingw-w64-x86_64-meson \ |
| 70 | + zip |
31 | 71 |
|
32 |
| -TODO |
| 72 | +Java (>= 7) is not available in MSYS2, so if you plan to build the server, |
| 73 | +install it manually and make it available from the `PATH`: |
33 | 74 |
|
| 75 | + export PATH="$JAVA_HOME/bin:$PATH" |
34 | 76 |
|
35 |
| -## Build |
36 | 77 |
|
37 |
| -The project is divided into two parts: |
38 |
| - - the server, running on the device (in `server/`); |
39 |
| - - the client, running on the computer (in `app/`). |
| 78 | +#### Mac OS |
40 | 79 |
|
41 |
| -The server is a raw Java project requiring Android SDK. It not an Android |
42 |
| -project: the target file is a `.jar`, and a `main()` method is executed with |
43 |
| -_shell_ rights. |
| 80 | +Use [Homebrew] to install the packages: |
44 | 81 |
|
45 |
| -The client is a C project using [SDL] and [FFmpeg], built with [Meson]/[Ninja]. |
| 82 | +[Homebrew]: https://brew.sh/ |
46 | 83 |
|
47 |
| -The root directory contains a `Makefile` to build both parts. |
| 84 | + # runtime dependencies |
| 85 | + brew install sdl2 ffmpeg |
48 | 86 |
|
49 |
| -[sdl]: https://www.libsdl.org/ |
50 |
| -[ffmpeg]: https://www.ffmpeg.org/ |
51 |
| -[meson]: http://mesonbuild.com/ |
52 |
| -[ninja]: https://ninja-build.org/ |
| 87 | + # build dependencies |
| 88 | + brew install gcc pkg-config meson zip |
53 | 89 |
|
| 90 | +Java (>= 7) is not available in Homebrew, so if you plan to build the server, |
| 91 | +install it manually and make it available from the `PATH`: |
54 | 92 |
|
55 |
| -### Build requirements |
| 93 | + export PATH="$JAVA_HOME/bin:$PATH" |
56 | 94 |
|
57 |
| -Install the [Android SDK], the JDK 8 (`openjdk-8-jdk`), and the packages |
58 |
| -described below. |
59 | 95 |
|
60 |
| -[Android SDK]: https://developer.android.com/studio/index.html |
| 96 | +### Common steps |
61 | 97 |
|
| 98 | +Install the [Android SDK] (_Android Studio_), and set `ANDROID_HOME` to |
| 99 | +its directory. For example: |
62 | 100 |
|
63 |
| -#### Linux |
| 101 | +[Android SDK]: https://developer.android.com/studio/index.html |
64 | 102 |
|
65 |
| - sudo apt install make gcc openjdk-8-jdk pkg-config meson zip \ |
66 |
| - libavcodec-dev libavformat-dev libavutil-dev \ |
67 |
| - libsdl2-dev libsdl2-net-dev |
| 103 | + export ANDROID_HOME=~/android/sdk |
68 | 104 |
|
| 105 | +Then, build `scrcpy`: |
69 | 106 |
|
70 |
| -#### Windows |
| 107 | + meson x --buildtype release --strip -Db_lto=true |
| 108 | + cd x |
| 109 | + ninja |
71 | 110 |
|
72 |
| -Install these packages: |
| 111 | +You can test it from here: |
73 | 112 |
|
74 |
| - pacman -S mingw-w64-x86_64-make |
75 |
| - pacman -S mingw-w64-x86_64-gcc |
76 |
| - pacman -S mingw-w64-x86_64-pkg-config |
77 |
| - pacman -S mingw-w64-x86_64-meson |
78 |
| - pacman -S zip |
| 113 | + ninja run |
79 | 114 |
|
80 |
| -Java 8 is not available in MSYS2, so install it manually and make it available |
81 |
| -from the `PATH`: |
| 115 | +Or you can install it on the system: |
82 | 116 |
|
83 |
| - export PATH="$JAVA_HOME/bin:$PATH" |
| 117 | + sudo ninja install # without sudo on Windows |
84 | 118 |
|
| 119 | +This installs two files: |
85 | 120 |
|
86 |
| -### Build |
| 121 | + - `/usr/local/bin/scrcpy` |
| 122 | + - `/usr/local/share/scrcpy/scrcpy-server.jar` |
87 | 123 |
|
88 |
| -Make sure your `ANDROID_HOME` variable is set to your Android SDK directory: |
| 124 | +Just remove them to "uninstall" the application. |
89 | 125 |
|
90 |
| - export ANDROID_HOME=~/android/sdk |
91 | 126 |
|
92 |
| -From the project root directory, execute: |
| 127 | +#### Prebuilt server |
93 | 128 |
|
94 |
| - make build |
| 129 | +Since the server binary, that will be pushed to the Android device, does not |
| 130 | +depend on your system and architecture, you may want to use the prebuilt binary |
| 131 | +instead: [`scrcpy-server.jar`](TODO). |
95 | 132 |
|
96 |
| -To run the build: |
| 133 | +In that case, the build does not require Java or the Android SDK. |
97 | 134 |
|
98 |
| - make run |
| 135 | +Download the prebuilt server somewhere, and specify its path during the Meson |
| 136 | +configuration: |
99 | 137 |
|
100 |
| -It is also pass arguments to `scrcpy` via `make`: |
| 138 | + meson x --buildtype release --strip -Db_lto=true \ |
| 139 | + -Dprebuilt_server=/path/to/scrcpy-server.jar |
| 140 | + cd x |
| 141 | + ninja |
| 142 | + sudo ninja install |
101 | 143 |
|
102 |
| - make run ARGS="-p 1234" |
103 | 144 |
|
104 |
| -The purpose of this command is to execute `scrcpy` during the development. |
| 145 | +## Run |
105 | 146 |
|
| 147 | +_At runtime, `adb` must be accessible from your `PATH`._ |
106 | 148 |
|
107 |
| -### Test |
| 149 | +If everything is ok, just plug an Android device, and execute: |
108 | 150 |
|
109 |
| -To execute unit tests: |
| 151 | + scrcpy |
110 | 152 |
|
111 |
| - make test |
| 153 | +It accepts command-line arguments, listed by: |
112 | 154 |
|
113 |
| -The server-side tests require JUnit 4: |
| 155 | + scrcpy --help |
114 | 156 |
|
115 |
| - sudo apt install junit4 |
| 157 | +For example, to increase video bitrate to 8Mbps (default is 4Mbps): |
116 | 158 |
|
| 159 | + scrcpy -b 8M |
117 | 160 |
|
118 |
| -### Generate a release |
| 161 | +To limit the video dimensions (e.g. if the device is 2540×1440, but the host |
| 162 | +screen is smaller, or cannot decode such a high definition): |
119 | 163 |
|
120 |
| -From the project root directory, execute: |
| 164 | + scrcpy -m 1024 |
121 | 165 |
|
122 |
| - make release |
| 166 | +If several devices are listed in `adb devices`, you must specify the _serial_: |
123 | 167 |
|
124 |
| -This will generate the application in `dist/scrcpy/`. |
| 168 | + scrcpy -s 0123456789abcdef |
125 | 169 |
|
126 | 170 |
|
127 |
| -## Run |
| 171 | +## Shortcuts |
128 | 172 |
|
129 |
| -Plug a device, and from `dist/scrcpy/`, execute: |
| 173 | + | Action | Shortcut | |
| 174 | + | ------------------------------------- | -------------:| |
| 175 | + | switch fullscreen mode | `Ctrl`+`f` | |
| 176 | + | resize window to 1:1 (pixel-perfect) | `Ctrl`+`g` | |
| 177 | + | resize window to remove black borders | `Ctrl`+`x` | |
| 178 | + | click on `HOME` | `Ctrl`+`h` | |
| 179 | + | click on `BACK` | `Ctrl`+`b` | |
| 180 | + | click on `APP_SWITCH` | `Ctrl`+`m` | |
| 181 | + | click on `VOLUME_UP` | `Ctrl`+`+` | |
| 182 | + | click on `VOLUME_DOWN` | `Ctrl`+`-` | |
| 183 | + | click on `POWER` | `Ctrl`+`p` | |
| 184 | + | turn screen on | _Right-click_ | |
| 185 | + | enable/disable FPS counter (on stdout) | `Ctrl`+`i` | |
130 | 186 |
|
131 |
| - ./scrcpy |
132 | 187 |
|
133 |
| -If several devices are listed in `adb devices`, you must specify the _serial_: |
| 188 | +## Licence |
134 | 189 |
|
135 |
| - ./scrcpy 0123456789abcdef |
| 190 | + Copyright (C) 2018 Genymobile |
136 | 191 |
|
137 |
| -To change the default port (useful to launch several `scrcpy` simultaneously): |
| 192 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 193 | + you may not use this file except in compliance with the License. |
| 194 | + You may obtain a copy of the License at |
138 | 195 |
|
139 |
| - ./scrcpy -p 1234 |
| 196 | + http://www.apache.org/licenses/LICENSE-2.0 |
140 | 197 |
|
141 |
| -Other options are available, check `scrcpy --help`. |
| 198 | + Unless required by applicable law or agreed to in writing, software |
| 199 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 200 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 201 | + See the License for the specific language governing permissions and |
| 202 | + limitations under the License. |
0 commit comments