# Scrcpy

```
sudo apt install adb ffmpeg libsdl2-2.0.0 make gcc pkg-config meson ninja-build libavcodec-dev libavformat-dev libavutil-dev libsdl2-dev
```

下載 <https://github.com/Genymobile/scrcpy/releases> 的 scrcpy-server-v1.10.jar

git clone <https://github.com/Genymobile/scrcpy.git>

```
cd scrcpy
meson build --buildtype release --strip -Db_lto=true  -Dprebuilt_server=scrcpy-server-v1.10.jar
cd build
ninja
sudo ninja install
```

{% embed url="<https://github.com/pierlon/scrcpy-docker>" %}

```
Host 機先執行
```

```
xhost
```

為AMD，Intel和Nvidia圖形硬件構建了單獨的圖像。要獲取硬件的圖像，只需附加`:<graphics type>`圖像名稱（`pierlo1/scrcpy`），其中圖形類型可以是：

* amd
* intel
* nvidia

```
xhost
docker run --rm -i -t --privileged \
    -v /dev/bus/usb:/dev/bus/usb \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    pierlo1/scrcpy:intel
```

#### 使用Docker Compose運行

要使用Docker Compose運行，請將`SCRCPY_GRAPHICS_TYPE`環境變量設置為前面提到的某種圖形類型。對於持久性，請複制`.env.example`，命名`.env`並配置它。

完成後，運行命令：

```
docker-compose run --rm scrcpy
```

#### 運行scrcpy

在容器內，確認您可以看到您的Android設備：

```
adb devices
```

adb devices List of devices attached

* daemon not running; starting now at tcp:5037
* daemon started successfully

  435be0d07ce5    unauthorized

adb devices&#x20;

List of devices attached

&#x20;435be0d07ce5 device

注意：確保host主機上沒有運行容器中 adb daemon的設備（`adb kill-server`）。

最後，運行`scrcpy`：

```
scrcpy [選項]
```

### 使用

#### 連接方法

**必備條件**

* 請確保  **adb , scrcpy**  可正常使用
* 請確保手機已打開USB 調試, 並已認證電腦調試

**有線連接**

1. 請確保手機已通過數據線連接到電腦
2. 等待自動檢測到設備
3. 選中設備
4. 等待設備打開

**無線連接**

1. 請確保手機與電腦處在同一網路
2. 第一次無線連接時:
   * **請確保手機已通過usb線連接到電腦**
   * **請確保只有一個手機通過usb線連接到電腦**
   * 第一次需設置端口，以後連接手機，只需要添加手機的靜態IP即可
3. 輸入手機的局域網`IP`地址（如果`IP`為`DHCP`分配，請更改為靜態`IP`）
4. 按下開啟無線連線
5. 等待無線連接成功
6. 選中設備
7. 等待設備打開


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kawsing.gitbook.io/opensystem/docker-cong-an-zhuang-dao-ying-yong-ru-men-pian/scrcpy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
