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

Error when using scrcpy-server directly #613

Closed
realyanyang opened this issue Jun 23, 2019 · 15 comments
Closed

Error when using scrcpy-server directly #613

realyanyang opened this issue Jun 23, 2019 · 15 comments
Labels

Comments

@realyanyang
Copy link

realyanyang commented Jun 23, 2019

I also want to get the video stream only from the android like #129 .
But when I run the command:

➜ /home/yanyang > adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 800000 true 
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: Expecting 5 parameters
	at com.genymobile.scrcpy.Server.createOptions(Server.java:71)
	at com.genymobile.scrcpy.Server.main(Server.java:132)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)

I use it in Ubuntu18.04

scrcpy 1.9

dependencies:
 - SDL 2.0.8
 - libavcodec 57.107.100
 - libavformat 57.83.100
 - libavutil 55.78.100

adb version: 1.0.41
Thanks.

@rom1v
Copy link
Collaborator

rom1v commented Jun 23, 2019

There are more parameters now:

adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 8000000 false - false true

See:

int maxSize = Integer.parseInt(args[0]) & ~7; // multiple of 8
options.setMaxSize(maxSize);
int bitRate = Integer.parseInt(args[1]);
options.setBitRate(bitRate);
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
boolean tunnelForward = Boolean.parseBoolean(args[2]);
options.setTunnelForward(tunnelForward);
Rect crop = parseCrop(args[3]);
options.setCrop(crop);
boolean sendFrameMeta = Boolean.parseBoolean(args[4]);
options.setSendFrameMeta(sendFrameMeta);
boolean control = Boolean.parseBoolean(args[5]);
options.setControl(control);

@rom1v rom1v added the question label Jun 23, 2019
@realyanyang
Copy link
Author

Thanks for your reply. It is the parameters problem.
But there are other problems:
adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 800000 true - true true
Then it block the terminal, is it normal?
Then I use another terminal run the command:
adb forward tcp:8080 localabstract:scrcpy
Then I run a python script just like #129 , I can get the dummy byte (0), but I can't get the next 68 bytes.
I try to wait a minute, but there are no bytes any more.

@rom1v
Copy link
Collaborator

rom1v commented Jun 24, 2019

Are there any relevant messages in adb logcat?

@rom1v
Copy link
Collaborator

rom1v commented Jun 24, 2019

Oh, of course it does not work anymore, now there are two sockets: ec71a3f.

adb push scrcpy-server.jar /data/local/tmp/scrcpy-server.jar
adb forward tcp:8080 localabstract:scrcpy
adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 800000 true - true true

Then you need to connect two sockets successively:

# video socket
nc localhost 8080

Then, in another terminal:

# control socket
nc localhost 8080

(the protocol between the server and the client is internal and can change at any time, I really need to expose a libscrcpy…)

@realyanyang
Copy link
Author

Thank you so much !!
It's an amazing job.
Looking forward to your libscrcpy.

@NickStemerdink
Copy link

I'm having the same problem when following the common steps of build.md.

./run x
2019-07-12 12:30:04.693 scrcpy[12993:8476893] DEBUG: Using SCRCPY_SERVER_PATH: x/server/scrcpy-server.jar
x/server/scrcpy-server.jar: 1 file pushed. 5.4 MB/s (19734 bytes in 0.003s)
ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: Expecting 5 parameters
	at com.genymobile.scrcpy.Server.createOptions(Server.java:53)
	at com.genymobile.scrcpy.Server.main(Server.java:109)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:308)

@rom1v
Copy link
Collaborator

rom1v commented Jul 12, 2019

You must use the same version for the client and the server.

So git pull and use the last prebuilt server.

@NickStemerdink
Copy link

Using the prebuilt server worked, thanks.

@siam-titan
Copy link

God I hope this thread isn't dead, I'm now facing an issue where after pushing the scrcpy-server file and adding classpath, I'm seeing that the client and server version doesn't match.

[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalArgumentException: The server version (1.24) does not match the client (0)
at com.genymobile.scrcpy.Server.createOptions(Server.java:167)
at com.genymobile.scrcpy.Server.main(Server.java:331)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)

Same commands were ran from above. I'm using scrcpy version 1.24, and downloaded the proper prebuilt server (scrcpy-server-v1.24) from the repo. Still the client version seems to show (0). What can I do?

@rom1v
Copy link
Collaborator

rom1v commented Oct 24, 2022

You must pass the paramters expected by scrcpy-server, as they are sent by the client: https://github.com/Genymobile/scrcpy/blob/v1.24/app/src/server.c#L163-L258

@siam-titan
Copy link

adb shell CLASSPATH=/data/local/tmp/scrcpy-server-v1.24 app_process / com.genymobile.scrcpy.Server 0 800000 true - true true

This is what I'm using, is there something wrong with the parameters I'm passing?

@rom1v
Copy link
Collaborator

rom1v commented Oct 24, 2022

This is what I'm using, is there something wrong with the parameters I'm passing?

Yes, this is wrong.

Check how the parameters are passed: https://github.com/Genymobile/scrcpy/blob/v1.24/app/src/server.c#L163-L258

adb shell CLASSPATH=/data/local/tmp/scrcpy-server-v1.24 app_process / com.genymobile.scrcpy.Server 1.24

is probably sufficient.

@siam-titan
Copy link

siam-titan commented Oct 26, 2022

After running the code, I'm getting this error now,

adb forward tcp:8091 localabstract:scrcpy
adb push scrcpy-server-v1.24 /data/local/tmp/
adb shell CLASSPATH=/data/local/tmp/scrcpy-server-v1.24 app_process / com.genymobile.scrcpy.Server 1.24

[server] INFO: Device: Google AOSP on IA Emulator (Android 9)
[server] ERROR: Exception on thread Thread[main,5,main]
java.io.IOException: Connection refused
at android.net.LocalSocketImpl.connectLocal(Native Method)
at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:292)
at android.net.LocalSocket.connect(LocalSocket.java:145)
at com.genymobile.scrcpy.DesktopConnection.connect(DesktopConnection.java:45)
at com.genymobile.scrcpy.DesktopConnection.open(DesktopConnection.java:72)
at com.genymobile.scrcpy.Server.scrcpy(Server.java:74)
at com.genymobile.scrcpy.Server.main(Server.java:335)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)

I'm having a really hard time understanding the code you provided unfortunately. What can I do now? An example would really help a lot .

@rom1v
Copy link
Collaborator

rom1v commented Oct 26, 2022

@siam-titan
Copy link

@rom1v thank you so much man, issues related to scrcpy was solved by that link. The stream works properly when I'm playing it with vlc/ffplay. But dunno why in the browser the video is corrupted. It's surely live because I can see the colors change when I interact with the emulator. I'm using h264-live-player library to decode the stream. Is there anything I can do now?

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

No branches or pull requests

4 participants