Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using another android device as client #100

Open
ghost opened this issue Mar 27, 2018 · 70 comments
Open

Using another android device as client #100

ghost opened this issue Mar 27, 2018 · 70 comments

Comments

@ghost
Copy link

ghost commented Mar 27, 2018

Thanks for this amazing project.
Is it possible to mirror one android screen to another android device using scrcpy-adb connect method? I found adb clients compiled for arm devices and also java implementation of adb client on github. What are your thoughts?

@rom1v rom1v changed the title Feature Request: Using another android device as client. Using another android device as client Mar 27, 2018
@rom1v
Copy link
Collaborator

rom1v commented Mar 27, 2018

As is, the client would require SDL and FFmpeg ARM versions, and wrap SDL stuff into an Android application.

But IMO it would be better to write a specific Android client, which would use the Android APIs instead of SDL and FFmpeg.

@NickAcPT
Copy link

+1 Would also like to see this turn into a feature.

@tailcode
Copy link

tailcode commented Jul 4, 2018

Hi @rom1v !
I am working on this. Is it okay to use the name scrcpy for the app?

@rom1v
Copy link
Collaborator

rom1v commented Jul 4, 2018

@tailcode The name should not be confusing about what application it is, so the very same name is not a good idea.

@tailcode
Copy link

tailcode commented Jul 4, 2018

@rom1v Thank you. Considering basic functionality of scrcpy, I think my app is ready but not perfect. This is my first app. I want you to take a look at my app and provide me with suggestions. So if you are okay with it please provide me with an email or any other medium to send the apk. And if possible kindly suggest some "wordplay" for the app name.

@NickAcPT
Copy link

NickAcPT commented Jul 4, 2018

Hey, sorry for bothering, but is there any plans to make it so there's almost no latency on the android app @tailcode is developing?
I know that might need some protocol redesign in order to acomplish such task..

@rom1v
Copy link
Collaborator

rom1v commented Jul 4, 2018

Considering basic functionality of scrcpy, I think my app is ready but not perfect. This is my first app. I want you to take a look at my app and provide me with suggestions. So if you are okay

Sure. Publish the code somewhere and I'll take a look when I have some time 👍

@tailcode
Copy link

@rom1v Here is the code. Thanks in advance.
https://gitlab.com/las2mile/scrcpy-android

@rom1v
Copy link
Collaborator

rom1v commented Jul 12, 2018

@tailcode Thank you very much. Seems great. 👍 I will definitely check when I have some more time.

For now, just one little remark: you could use adblib as a dependency instead of a copy-paste of their source code:

compile 'com.tananaev:adblib:1.2'

@tailcode
Copy link

@rom1v Thank you very much. I agree with you. But I have made small changes to AdbCrypto.java file of adblib. I will see if I can isolate those changes. Meanwhile one issue that I came upon while using the app is, I am unable to open items in gallery and file manager of remote device. When I click on an image or video thumbnail, instead of opening, they are being selected. Please enlighten me if I am missing something.

@rom1v
Copy link
Collaborator

rom1v commented Jul 18, 2018

@tailcode Hey, I just tested, that works great 👍 Good job!

Is it possible to quit from the client? (I only see the remote fullscreen, so I can't control the client device)

Also, if the devices have a different aspect ratio (typically if I force the navbar to be displayed), the video aspect-ratio is not preserved.

When I click on an image or video thumbnail, instead of opening, they are being selected.

I think there is a similar problem with VLC: if I click quickly while a video is playing, it should display the control bar, but it does not.

@tailcode
Copy link

@rom1v Thank you very much for the feedback.

Is it possible to quit from the client?

Yes, when you exit from the app, socket pipe breaks and server terminates. Cleaning of remote device is handled in server code.

I only see the remote fullscreen, so I can't control the client device

You mean input events are not working ? I have tested on few devices and they worked for me. Please let me know what device you are using and I will try to test on it if I can find it in my circle.

One hurdle I have encountered on a Samsung device is, it doesn't have curl or wget binaries in it and the server cannot be downloaded to it by the current implementation. I don't know if all samsung devices are so. I have worked on a new method to push server to remote device which I am testing. I will push them to git once I think it is ready.

@rom1v
Copy link
Collaborator

rom1v commented Jul 20, 2018

when you exit from the app

How do you do that? The whole client screen displays the remote screen.

You mean input events are not working ?

Yes, input events are workings: they are forwarded to the remote device.

@tailcode
Copy link

@rom1v Sorry, I mistook your question.

Is it possible to quit from the client?

Just swipe from bottom edge of screen. You will see android navigation bar.

@robsmith11
Copy link

robsmith11 commented May 14, 2019

srccpy-android works really well for me, especially after changing my phone's aspect ratio to match my tablet's with adb shell wm size 1080x1440.

Even with just a wifi connection, the latency is low enough to type without any lag on my bluetooth keyboard, scroll webpages, and watch videos.

Maybe a link could be added in scrcpy's README?

@k3dar
Copy link

k3dar commented Jun 8, 2019

@tailcode thanks for android client, having problem with landscape device, more info: https://gitlab.com/las2mile/scrcpy-android/issues/3

@RomSand
Copy link

RomSand commented Sep 16, 2019

It works only wiressly, no USB OTG support ?
Thanks.

@parkerlreed
Copy link

Any APK for scrcpy-android? Would love to try it out.

@robsmith11
Copy link

@parkerlreed
https://gitlab.com/las2mile/scrcpy-android/raw/master/release/scrcpy-release.apk

It works pretty well for me over wifi, but would have lower latency I think if USB connections were supported.

@parkerlreed
Copy link

Cheers! Working quite well with Pixel 3 XL host and Fire HD 8 as client

@billymcintosh
Copy link

billymcintosh commented Nov 15, 2019

Tried with Xiaomi Mi 9 and Nvidia Shield TV. No dice. It seems to connect but it's just a blank screen.

Scratch that ^

Shield was on ethernet whilst phone was on Wifi. Works when both on wifi.

@brunoais
Copy link
Contributor

brunoais commented Dec 5, 2021

For X11, I use x11vnc (available both in apt and pacman package managers).
For Wayland, we probably have to wait for pipewire to be more mature because without it, it's very complicated to have the images of the desktop so it can be remotely controlled.

@eGit
Copy link

eGit commented Dec 5, 2021

Thanks. I will check it out. Happy for more suggestions.

@rhjdvsgsgks
Copy link

Controlling windows remotely is a huge "can of worms". Lots of COM to connect to and hoops to jump through. A Linux stack is not as complex but would require supporting multiple means to achieve it (don't quote me on this because this is 2nd hand information) A MacOS cannot be controlled by software that isn't signed and, in some way, "approved" by Apple (same kind of signing windows already enforces for some things).
On Android, the means are straightforward-enough and there's almost one way that works in nearly all phones.
It's a difference between bloated software filled with bugs and no time to fix them and small software which solves 1 "small" problem in its essence.
If you still think it's easy to make the opposite while it hasn't been solved yet in open-source such as placing a VNC server on the OS and having a VNC client on your android phone, then feel free to bring a counter-argument.

Thanks for the explanation - I really was just curious as I have no clue. What is the best existing solution (performance both via Wifi and direct USB tethering) using Linux on an Android client? What is the best open source solution?

https://github.com/kokoko3k/ssh-rdp or https://github.com/loki-47-6F-64/sunshine , both support kmsgrab+vaapi, which significant improve experience.

@beckietech
Copy link

Thank you @rom1v! Hi @tailcode, you've made a wonderful project, and I managed to mirror my android 10 screen cast to android 11!
"Mirrors devices upto android 10. Android 11 wireless debugging needs to be worked out."
Since you've mentioned to work it out on android 11 screen cast, I wonder have it sone yet? I observed the project and found there's server along side with app, and I wonder if it's possible to using the cast from android 11 above and forward them to port 5555? Is it possible?

@rom1v rom1v mentioned this issue Mar 24, 2022
1 task
@xAffan
Copy link

xAffan commented Mar 24, 2022

This issue has been open for almost 2 years. I hope we approach towards a resolution soon.

@rom1v
Copy link
Collaborator

rom1v commented Mar 24, 2022

There are no plan to develop and maintain an Android client of scrcpy. You can test the prototype from @tailcode here: #100 (comment)

@stefan-sherwood
Copy link

Wouldn't it make sense to allow controlling a Win/OSX/Linux PC from an Android device?

Chrome Remote Desktop app works perfectly for this

@brunoais
Copy link
Contributor

brunoais commented Aug 1, 2022

Maybe also rustdesk works also but I'm not sure about the server part of the process...

@mouedarbi
Copy link

mouedarbi commented Oct 3, 2022

Hi @tailcode,, i have tryed your app and work perfectly !!
Can i ask you to add a change for cropyng the screen, ? I am using it to stream VR headset to a tablet but i see the image (eye) so i need that scrcpy start but with a command argument -c 1000:1000:110:220 to have only one screen not 2 binocular image.

@parkerlreed
Copy link

parkerlreed commented Oct 20, 2022

Can't believe this hasn't been mentioned. WebADB includes a port of scrcpy that you can use straight from a web browser.

https://yume-chan.github.io/ya-webadb/

@mouedarbi It allows cropping as well :)

image

@parkerlreed
Copy link

Example using Quest 2 and termux on the client device

Screenshot_20221020_002925_Kiwi Browser
Screenshot_20221020_002948_Termux

@parkerlreed
Copy link

And cropping
Screenshot_20221020_003215_Kiwi Browser

@mherrmann3
Copy link

mherrmann3 commented Jan 4, 2023

@parkerlreed: thanks for pointing to the webdemo of ya-webadb!

Just to highlight again what is not directly apparent from those screenshots: ya-webadb allows using scrcpy (and more) over the USB cable to another Android device! That's what I was desperately looking for (i.e., not needing any network connection whatsoever, apart from initially loading the demo).
It's extremely responsive (low latency) with high quality—it seems the copied screen is from the same device. Best mirroring solution so far.

Kudos to @yume-chan.

@bladyle
Copy link

bladyle commented Feb 6, 2023

@parkerlreed: thanks for pointing to the webdemo of ya-webadb!

Just to highlight again what is not directly apparent from those screenshots: ya-webadb allows using scrcpy (and more) over the USB cable to another Android device! That's what I was desperately looking for (i.e., not needing any network connection whatsoever, apart from initially loading the demo). It's extremely responsive (low latency) with high quality—it seems the copied screen is from the same device. Best mirroring solution so far.

Kudos to @yume-chan.

Can you share how you manage to connect two phones via USB cable? Are you using ya-webadb via browser? Is there a way to run it locally not from browser.

@mherrmann3
Copy link

@bladyle: Yes, exactly: I used the mobile browser and surfed to yume-chan.github.io/ya-webadb/scrcpy. Not sure how it should run without a browser. 🤷‍♂️
Connect both devices by USB (USB Debugging has to be enabled & set up on the other phone), and connect them via ya-webadb's interface.

Tip: For the connection to work, make sure that your mobile browser supports WebUSB. For instance, on an older phone, I had to first update Android WebView to a fairly recent version before it worked.

@bladyle
Copy link

bladyle commented Feb 15, 2023

@mherrmann3 Thanks, manage to connect two phone, but still as you wrote you need newer phone with supported browser.

@DienoX
Copy link

DienoX commented May 13, 2023

Would it be possible to create an official fundraiser for @rom1v to add an Android client?

Looking at the fact that there is a lot of interest, only 10 USD from 100 people would be enough to collect an interesting amount. It's $1,000, but it's possible more people would have cashed out or more.
I myself would very much like to donate $10 to support the development of this wonderful project.

A huge request from me is that the creator of the collection is @rom1v as the trusted owner of this product. I saw that there are ready projects that enable such fundraising that are integrated with github.

@Rajah01
Copy link

Rajah01 commented Nov 8, 2023

Genymobile's current Linux version (at this date, v2.1.1) is ported to Android in termux-x11. After initially "authorizing -- always Allow" the Android server (your device) on the Android client (mirrored) device (with a USB cable), you can use either USB or TCPIP (TCP enables remote connections: issue "termux-adb tcpip 5555", or another port_number).

I find that a cellular IPv6 connection is most reliable for remote handling, because it disregards potential issues with router forwarding (accordingly, an important Developer option in Android 13|14 on the client is "Mobile data always active", alongside "Disable adb authorization timeout", etc.). Assumptions: both ISP APNs use IPv6 by default, and that the ISPs or devices don't filter or block outgoing/incoming connections.

My prerequisites:
-- RealVNC Viewer (or e.g. F-Droid's AVNC) app installed
-- x11 installed (termux-x11, etc -- see further the Termux "Graphical Environment" wiki)
-- xfce4 installed as my x11 Desktop in Termux
-- termux:API app from F-Droid|Github, and termux-api, termux-adb, tigervnc, and scrcpy packages installed in Termux

My procedure:
-- issue in Termux:
vncserver -localhost (launch tigervnc and get a :DISPLAY number)
export DISPLAY=":1" (or the display number that the "vncserver -localhost" command reports)
-- for TCP connections only, issue in Termux:
termux-adb connect [$client_IP_address]:$port (brackets [ ] for IPv6 only; $port usually 5555)
-- add the DISPLAY number to 5900, e.g. if DISPLAY=":1" then port=5901
-- connect the RealVNC Viewer app to, e.g., "127.0.0.1:5901". Verify that you have an x11 window!
-- issue in Termux or in xfce's Terminal Emulator:
scrcpy --stay-awake --time-limit=0 --serial [$client_IP]:$port >/dev/null &

It works: video, audio, everything ... Most of the above can be scripted.

For a remote connection, the "trick" (and the rub) is to learn or know the client's IP address! In practice, assuming both Android devices are truly mobile (acquiring short-term IP addresses), the client must report (using http, curl, wget, ssh, etc) its current address(es) periodically to a third party device with a known or static IP, mutually accessible by both server and client. For example, the third party might employ a simple PHP routine (using, e.g., $_SERVER["REMOTE_ADDR"]) to detect the address of an incoming connection, store it in an array or file, and report it if queried. If server wants to use the client's cellular address, an unrooted,client must disable WiFi; if rooted, the client can detect it's IPv6 cellular address from rmnet in "ifconfig -S" and post that to the third party, while WiFi remains "up".

@KaKi87
Copy link

KaKi87 commented Jan 26, 2024

Hello,

Any news on this ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests