-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Is it possible to redirect the stream to another application ? #1073
Comments
Thanks, I will try if I could find what I need with this project. For now, it just seems to offer the same features. |
The proper way would be to split scrcpy in two parts: libscrcpy and the UI (#707 (comment)). But this is not done. Another way could be to use only the .jar on your side, and write your client which mimic the protocol used between the client and the server (but this protocol should be considered private, i.e. it may change at any time). Alternatively, you could fork current master and replace some parts… |
That's pretty much what I did - just take the Java portion that already sends back H.264 stream (with initial custom header), and just handle H.264 stream inside your desktop application (or where ever you want to consume it). Basically reuse the server jar, but dump viewer in favor of your own stream handling and visualization. On a separate note, @rom1v , did you notice from screenshots above that QtScrcpy seems to be supporting audio? I know you tried USBAudio (I'm looking into it now myself), but quick look (really, probably not even 2 min spent on it) at QtScrcpy source, I couldn't see much for audio handling. Have you looked into it and see if it something more solid than USBAudio? |
I don't think so. They're just shortcut for volume up/down on the device. Also see #612.
The real solution will be the Playback Capture API introduced in Android Q. See #933. |
Yeah, I know about Playback Capture API (I've been all over the threads, esp #14 one) - unfortunately it is insufficient for what I need... |
Why? |
I mean it would "help somewhat" in that it will allow for a small sliver of audio to be captured, but it is a co-operative solution between apps and the capturing app (the app has to explicitly allow for its audio to be captured), and, as far as I understand, would only work with a small subset of apps and none of the system sounds. It seems PCAPI was designed for a very very narrow use case like streaming of game playing, rather than general-purpose API. In other words, in scrcpy analogy, only being able to capture screen when a co-operating game is being played, but otherwise getting a blank screen in all other cases - much more limited and thus much less useful. |
I did not investigated yet, but by calling private API with shell permissions, it is maybe possible to capture the audio from any app (I'm not sure). For example, the |
Hi @LBensman ,
Could you help me with that part? Should it work if I'm just launching server .jar? Because, I guess, it requires to modify the scrcpy code, but It could be very helpful if you help me where. I want to display the video stream in a Unity app, I can handle H.264 stream from the "receiver" side, but I'm just stuck trying to find a way to modify scrcpy to send back H264 to it. Thanks, |
A proper solution could be to implement an option For example, it would be used like this:
That way, once implemented, anyone could receive the raw video stream. It's not a priority for me, but if you work on something that requires it, you could implement it that way and submit a pull request. 😉 |
Yes, this solution could be great and easy to use. Thanks for the suggestion! I can for sure understand that isn't a priority for you ;). Since I'm not an expert in java development, I'm not sure I will be able to do it properly but I'm still going to start investigating the code and try (If anyone who is reading this post wants to join ;) ). Have you any tips? I have read the developer readme but it would be helpful to know which IDE (for example) should be used to edit your project. I'm using Android Studio for the server-side but which IDE are you using for the client development and to build scrcpy.exe? Thanks for your time, |
This feature has to be implemented on the client-side, which is in C 😉 Basically, when you receive a packet, it is decoded + recorded (if necessary): Lines 81 to 97 in 3935660
We can, in addition, write it to a socket. But in fact, it could even be written earlier (without even parsing it): Line 229 in 3935660
Whatever you want. I use |
Hi, I don't know if I should create another topic about creating an First in
Then in
I would like to split the args 'tcp:localhost:1234' and use Thanks again for your time, |
https://github.com/qaisbayabani/SCRCPY-C-Sharp-Client is a demo to show a self made application for scrcpy output |
Hi @qaisbayabani ! Thanks for the demo ! I tried but I got a |
i have made 100% working clients for both c# and java is available on request if the party needs it so deperetly a one page 100 line code. |
mr darkroll u r using an emulator? adb commands must be reconfigured according to your own environment other things will work fine. i have deleted this demo repository because i have developed a flawless full alpha version now which is working 100% fine soon i will load it to repository if you could get me screenshots of output window than may i could understand that will be a thanks for your response. |
Hey, any chance you could share the C# Code or are you still working on a functioning version? |
@qaisbayabani I'm interested to see it too. |
the version mr.darkroll was downloaded is also a working one. |
is it working or still error |
as i guess u were using an emulator u should use a phone and tell the room is it working at ur side |
@qaisbayabani I'm using it with a VR Headset based on Android. I still have a Connection refused with the first demo you posted. My version allows forwarding the packet received on another socket. In your demo, you directly push the scrcpy-server and connect to it. It is very helpful to understand how you integrated it into a C# solution. |
https://github.com/qaisbayabani/SCRCPY-C-Sharp-Client |
Mr. Overvox
its here |
@qaisbayabani I don't have the connection refused any more. But It's still not working for me. I always have a gray screen with "Empty" outputs. |
|
I tried using USB Cable on VR Headset (Android 8) and my phone too (Android 10). I got the "Third is Gneeal" error and receiving "Empty" outputs each time. |
@qaisbayabani hi, I have Android 9 (samsung galaxy s8+). I tried over wifi and usb cable. And same result. just "empty" outputs. |
Hi @hgedik, I manage to make it works for me. I change from |
I guess that u just have to just start the screen of mobile (or play some thing youtube etc) before running the debug. and as drakol may u have to adjust Cv2.Waitkey(1). if u change the waitkey than u may have not even to start the screen before debug. waiting from ur side. :) |
its good to listen that its working for u. u can see its just taking few lines of codes and needs just few more for universal plug and play. Cv2.WaitKey(1) is the best and ideal for all. |
I think the basic question is solved that yes it is possible to redirect the stream to another application.
|
Hi @qaisbayabani, I don't really know C#, but just a few remarks. I don't know how The framerate of the video is very variable: a new frame is produces whenever the screen content changes. If it does not change for 10 seconds, there are no frames. If it changes 90 times per second, then the framerate is 90fps. The |
and video: https://www.screencast.com/t/bPdjdgkD9 |
you have to just add nuget package opencvsharp4 from nuget manager in visual studio. and try with http://localhost:27184 why i see tcp://localhost:27184 in your outputimage |
thanks for remarks but i strongly rely on "WYSIWYG" WHAT YOU SEE IS WHAT YOU GET. i have checked it with stop watch app running in mobile that there is no delay at all. thaks for your input and i want your point to be elebortated more that i can learn more from your input. |
@qaisbayabani I don't get why Also, if you want to upgrade using scrcpy-server.jar 1.13 instead 1.12.1, here is my command with the new arguments :
|
you may have to instal IIS for windows and start it u can also use ip address assigned by your local wifi router to your pc |
there are thousands of pages written on web about ffmpeg conversion, listening H264 stream and conversion, encoders decoders bla bla.... i have just here to cover as written in my repository readme it covers. multithreading a single file program.cs converting smooth capture from scrcpy-server to c# client adb commands using c# server port opening reading server received data and forwarding the stream to other port. opencv capture from network stream and disply H264 stream from android screen capture. cross plateform stuff. enjoy only for teaching purpose. and a real world working example of serving that purposes. |
@qaisbayabani Thanks for sharing the script man. I am trying to run this and I am getting a similar issue as the other. When throw the exception that results in "Third is Gneeal" I get the following:
I tried what others had suggested and am still getting the same issue. @Darkroll76 would you be able to share your version of the working script? |
I recreated the same script as @qaisbayabani in python, which seems to work. The python script: import cv2
import socket
from multiprocessing import Process
from tqdm import tqdm
def main():
s_input = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s_input.bind(('127.0.0.1', 27183))
s_input.listen(1)
conn, addr = s_input.accept()
print("Connection details: ", conn, addr)
print("Device: ", conn.recv(64).decode('utf-8'))
print("Width? ", int.from_bytes(conn.recv(2), "big"))
print("Height? ", int.from_bytes(conn.recv(2), "big"))
s_output = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s_output.bind(('127.0.0.1', 27184))
s_output.listen(1)
p = Process(target=client)
p.start()
out_conn, addr = s_output.accept()
print("\n", "Connection details: ", out_conn, addr)
while True:
out_conn.send(conn.recv(1))
p.join()
def client():
cap = cv2.VideoCapture("tcp://127.0.0.1:27184")
print(cap)
for _ in tqdm(range(1000)):
r, img = cap.read()
if not r:
continue
cv2.imshow("", img)
cv2.waitKey(20)
if __name__ == "__main__":
main()
# client() I tried removing the |
correct question |
the flawless version as promised is updated on 02.04.2022 and posted on my repo hope u will find it help full https://github.com/qaisbayabani/SCRCPY-C-Sharp-Client this is to make all the previous issues void and have a cutting edge tech to decode stream at pc client. new code making all previous issues void. |
i have done it for android 13 also but not uploaded yet |
Hi,
Currently, scrpcy opens independent windows to render video stream but I'm trying to integrate it inside an application. Is there any way to do it? By redirecting the stream?
It could be a Unity App or Java App or C# UWP App but I would like to be able to share android-based VR headset screen (Oculus Go, Quest, PICO, etc) inside a desktop application.
Thanks for your time,
Killian
The text was updated successfully, but these errors were encountered: