-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Get the video stream only from the android #129
Comments
Yes, you can connect to the socket, and mimic the protocol used between the client and the server:
(see After these 68 bytes, you receive the raw H.264 stream ( |
I have tried the method you mentioned, but come with some problems: #coding=utf-8
import socket
import struct
port = 8080
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 8080))
deviceName = sock.recv(64)
print len(deviceName), deviceName[-1]
print str(deviceName), 1111111
width = sock.recv(2)
print struct.unpack("H", width)
height = sock.recv(2)
print struct.unpack("H", height)
sock.close()
|
It receives it exactly once. If you retry after the server is shutdown, your script will just print 0 (
I guess
Yes, that's expected (when you close the |
Thanks for you answer, it helps a lot! |
This is a very nice project! |
I forgot to mention a very important detail: in |
Thank you for your mention, I got what the first byte means. |
One more question: |
I got a working example based off what you started, @likezjuisee . It connects to the SCRCPY server as you've done, then creates a SubProcess Pipe to FFplay from the FFmpeg suite and pipes all video data received directly into there. See the Gist linked below including Bash and Windows helper scripts to launch the server. https://gist.github.com/Allong12/a752decf49e6c789c2425e35028137a5 Next step is piping into FFmpeg and recieving the decoded image into a Python NumPy array or the like |
In fact I kinda just went ahead and started my own project on all of this. I've got FFmpeg processing all of the network frames, and then Python converting them into a friendly Numpy Array See what you think: |
Hi, with the newest scrcpy-server.jar, I can't received the h264 data as before, is there something changed? try {
Ln.d("waiting client connect...");
videoSocket = localServerSocket.accept();
Ln.d("client connected and write 0");
// send one byte so the client may read() to detect a connection error
videoSocket.getOutputStream().write(0);
try {
controlSocket = localServerSocket.accept();
} catch (IOException | RuntimeException e) {
videoSocket.close();
throw e;
} |
Nice, I guess you may use the screen data as th ML input data? |
Yes, that changes all the time. #673 (comment)
|
I have read the code, videoSocket and controlSocket must are connected both, I will use the videoSocket only. |
For those who is looking for the answer: Also there is control mixin class that can send swipe command to scrcpy server. It can be extended. |
a single file solution in c# |
After I have executed the command
adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 8000000 true
, how can I get the video stream from the phone? Maybe the reversed socket "scrcpy"?My purpose is get the video stream and transform it to rtmp format, display it on the website.
The text was updated successfully, but these errors were encountered: