leng-yue / py-scrcpy-client

An easy to use python scrcpy client
https://leng-yue.github.io/py-scrcpy-client/
MIT License
290 stars 74 forks source link

scrcpy from commandline works but scrcpy-client-0.3.5 doesn't #11

Closed wildsheepz closed 2 years ago

wildsheepz commented 2 years ago

Hi, I am encountering an issue with scrpy-client-0.3.5 (and scrpy-client-0.3.6) and I am not sure how to get it to work. Running scrcpy directly works as expected but using python didn't work for me. Any idea how to solve this? screencapture video

ADB Logcat 11-22 18:57:56.778 1411 1411 E adbd : failed to connect to socket 'localabstract:scrcpy': could not connect to localabstract address 'localabstract:scrcpy'

wildsheepz commented 2 years ago

If I set a breakpoint to at core.py and wait a little before continuing code execution, it will work: screencapture video

leng-yue commented 2 years ago

Seems like pushing the ADB server exceeds 3 seconds and causes a timeout. And in the official scrcpy, it takes more than 3 seconds too.
I will release a fix to allow you to set a custom timeout.

leng-yue commented 2 years ago

I will also add something to wait for the server to start.

leng-yue commented 2 years ago

It should be fixed now, can you try the newest version from GitHub? (NOT PYPI)

leng-yue commented 2 years ago

Or you can update the core.py manually

wildsheepz commented 2 years ago

There is still has an error but you are right about waiting for the server.

kuanyong@kuanyong-GP66:~/Desktop/MyProjects/pq3$ python3 client.py 
[AdbDevice(serial=8AFX0RRXU)]
Traceback (most recent call last):
  File "client.py", line 22, in <module>
    client.start(threaded=True)
  File "/home/kuanyong/.local/lib/python3.8/site-packages/scrcpy/core.py", line 153, in start
    self.__deploy_server()
  File "/home/kuanyong/.local/lib/python3.8/site-packages/scrcpy/core.py", line 142, in __deploy_server
    self.__server_stream.check_okay()
  File "/home/kuanyong/.local/lib/python3.8/site-packages/adbutils/__init__.py", line 171, in check_okay
    raise AdbError("Unknown data: %s" % data)
adbutils.errors.AdbError: Unknown data: [ser
kuanyong@kuanyong-GP66:~/Desktop/MyProjects/pq3$ 
wildsheepz commented 2 years ago

When the server is started it prints the device name after a pause:

kuanyong@kuanyong-GP66:~/Desktop/MyProjects/pq3$ adb push /usr/local/share/scrcpy/scrcpy-server /data/local/tmp/scrcpy-server.jar && adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.20 info 0 100000 1 -1 true - false true 0 false false - - false
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 3.9 MB/s (37139 bytes in 0.009s)
[server] INFO: Device: Google Pixel 3 (Android 12)
leng-yue commented 2 years ago

V0.3.7 is publishing, and the problem should be solved. Can you try it 10 minutes later?

wildsheepz commented 2 years ago

It works now, thanks!