Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.02k stars 10.01k forks source link

Fail to remotely use scrcpy from MacOS to access the Pixel device connected with Ubuntu host #4885

Open Songchunbo opened 3 weeks ago

Songchunbo commented 3 weeks ago

Environment

Describe the bug

I have a Ubuntu host directly connected to a Pixel device via usb cable. It's normal to use scrcpy from the Ubuntu console. When connected, the console displays the following.

$ scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  FA68Yxxxxxxx                    device  AOSP_on_msm8996
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 1.8 MB/s (69007 bytes in 0.036s)
[server] INFO: Device: [google] Android AOSP on msm8996 (Android 8.1.0)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: opengl
INFO: OpenGL version: 3.1 Mesa 21.2.6
INFO: Trilinear filtering enabled
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1080x1920

When I SSH into the Ubuntu host from MacOS via iTerm and then try to use scrcpy, it complains with the following errors.

$ scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
ERROR: Could not initialize SDL video: No available video device
ERROR: Could not start adb server

So, is it possible to remotely use scrcpy from MacOS to access the Pixel device connected with Ubuntu host? or some packages I missed in MacOS?

rom1v commented 3 weeks ago

Over SSH, you won't have a display by default. Even if you forwarded display via SSH (ssh -X), this is not what you want: you want to transmit the compressed video stream, not the image to display.

For that purpose, read https://github.com/Genymobile/scrcpy/blob/master/doc/tunnels.md#ssh-tunnel

Songchunbo commented 3 weeks ago

Thanks, rom1v. I think SSH tunnel forward is correct way in my scenario.

I followed the SSH tunnel guide and made the tests with a Pixel device. However, the connection appears to be unstable. Initially, the device screen is displayed correctly during the first two attempts, but subsequent tries result in it being blocked. Is there any log to check the block reason?

****************************first try********************************

(base) % export ADB_SERVER_SOCKET=tcp:localhost:5038
(base)  % scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  FA68R0309644                    device  Pixel
/opt/homebrew/Cellar/scrcpy/2.4/share/scrcpy/scrcpy-server: 1 file pushed. 3.5 MB/s (69007 bytes in 0.019s)
[server] INFO: Device: [Google] google Pixel (Android 10)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: metal
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1080x1920
^CWARN: Device disconnected

****************************second try********************************
(base)  % scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  FA68R0309644                    device  Pixel
/opt/homebrew/Cellar/scrcpy/2.4/share/scrcpy/scrcpy-server: 1 file pushed. 2.3 MB/s (69007 bytes in 0.029s)
[server] INFO: Device: [Google] google Pixel (Android 10)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: metal
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1080x1920
^CWARN: Device disconnected

****************************third try********************************
(base)  % scrcpy
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  FA68R0309644                    device  Pixel
/opt/homebrew/Cellar/scrcpy/2.4/share/scrcpy/scrcpy-server: 1 file pushed. 3.1 MB/s (69007 bytes in 0.021s)
[server] INFO: Device: [Google] google Pixel (Android 10)
[server] WARN: Audio disabled: it is not supported before Android 11