TOP

2019年8月28日 星期三

透過 scrcpy 將 Android 手機畫面投影至 Windows 下

scrcpy 是在 Windows 下執行的程式, 透過 ADB 可將手機畫面輸出至此程式

 

 

Features

[1] Windwos 下透過滑鼠操作 Android 手機

[2] 按右鍵可喚醒手機

[3] USB 連接手機

[4] USB 完成設定後也可改由用 wifi 連線 (之後不用再透過 USB )

 

應用場景 -> 玩遊戲:

[優點] 某些遊戲無法在模擬器 (ie: BlueStacks) 上執行, 但又希望可使用電腦上的資源 (例如: 大螢幕, 鍵盤輸入, USB 搖桿), 可在手機上執行遊戲, 再透過  scrcpy 輸出至電腦螢幕使用鍵盤滑鼠搖桿等進行控制

[缺點] 畫面輸出至 scrcpy 會有些許延遲 (lag)

 

 

Requirements

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

 

Make sure you enabled adb debugging on your device(s).

On some devices, you also need to enable an additional option to control it using keyboard and mouse.

<來自 https://github.com/Genymobile/scrcpy>

 

手機端

 · Android  5.0 以上

 · 啟用 ADB debug mode

電腦端

 · 測試環境: Win7x64

 · 安裝 ADB 驅動程式 (由手機開發商提供, 需去官網找)

 

 

Download

https://github.com/Genymobile/scrcpy

 

 

執行 scrcpy

 

PS C:\Program Files\scrcpy-win64-v1.10> .\scrcpy.exe

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>

C:\Program Files\scrcpy-win64-v1.10\scrcpy-server.jar: 1 file pushed. 0.3 MB/s (22546 bytes in 0.081s)

INFO: Initial texture: 2280x1080

INFO: New texture: 1080x2280

INFO: New texture: 2280x1080

INFO: New texture: 1080x2280

[server] WARN: Could not inject char u+8857

INFO: New texture: 2280x1080

INFO: New texture: 1080x2280

INFO: New texture: 2280x1080

 

 

 

Troubleshooting

ADB error:

PS E:\temp> ./scrcpy

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>

adb: error: failed to get feature set: no devices/emulators found

ERROR: "adb push" returned with value 1

Press any key to continue...

 

<1> 確認手機上開發者模式有打開

<2> Windows 上需要額外的 driver

On Windows, my device is not detected

The most common is your device not being detected by adb, or is unauthorized. Check everything is ok by calling:

 

adb devices

Windows may need some drivers to detect your device.

https://developer.android.com/studio/run/oem-usb.html

https://www.asus.com/support/utilities/zencare/download_driver.aspx?ln=zh-tw&l1=39&l2=1&l3=0&m=2&os=32

 

<3> 重新 disable/enable 開發者模式, 重新插拔 usb cable

<4> 重啟 ADB server

adb kill-server

adb start-server

 

參考 https://github.com/Genymobile/scrcpy/issues/354

You have two problems here:

i.    You already have some adb daemon v39 running on your computer (something which uses adb). If this running daemon is not reexecuted as soon as it is killed, executing adb devices one more time should not print adb server version (40) doesn't match this client (39); killing.... You should find the software which executes adb v39.

ii.    Device is unauthorized if you didn't authorize the connection on your device. A popup should open when you connect a device via adb. Some buggy devices don't always show this popup immediately. In that case, try adb kill-server; adb start-server, unplug-replug, and if nothing works, use an old adb (v39 or v36).

 

 

Performance improvement

透過降低解析度的方式來提升效能 => 使用 -m 參數:

scrcpy -mXXX (XXX 為解析度, 例如: scrcpy -m640)


640

不清楚

960

ok

1080

ok

<來自: https://github.com/Genymobile/scrcpy/issues/208>

 

Wireless

1. Connect the device to the same Wi-Fi as your computer.

2. Get your device IP address (in Settings About phone Status).

3. Enable adb over TCP/IP on your device: adb tcpip 5555.

4. Unplug your device.

5. Connect to your device: adb connect DEVICE_IP:5555 (replace DEVICE_IP).

6. Run scrcpy as usual.

<來自 https://github.com/Genymobile/scrcpy>

 

PS C:\Program Files (x86)\scrcpy> ./scrcpy

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>

C:\Program Files (x86)\scrcpy\scrcpy-server: 1 file pushed. 0.4 MB/s (26202 bytes in 0.059s)

INFO: Initial texture: 1080x2280

[server] INFO: Device rotation requested: landscape

 

PS C:\Program Files (x86)\scrcpy> .\adb.exe tcpip 5555

restarting in TCP mode port: 5555

此時可拔除 USB cable !!!

 

PS C:\Program Files (x86)\scrcpy> ./adb connect 192.168.0.100:5555

connected to 192.168.0.100:5555

 

PS C:\Program Files (x86)\scrcpy> ./scrcpy

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>

C:\Program Files (x86)\scrcpy\scrcpy-server: 1 file pushed. 0.5 MB/s (26202 bytes in 0.053s)

INFO: Initial texture: 1080x2280

INFO: New texture: 2280x1080

INFO: New texture: 1080x2280

INFO: New texture: 2280x1080

INFO: New texture: 1080x2280

 


沒有留言:

張貼留言