Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
110.45k stars 10.58k forks source link

Recording not working? #5333

Open Mindputty opened 2 weeks ago

Mindputty commented 2 weeks ago

Are there any known issues with using scrcpy in python scripts, specifically in how subprocess.Popen() has trouble with recording to file? I can record from command line, but when I try from within my script, the behaviour is unpredictable, recording only about 1% of the time, with the other 99% of the time being either 0 KB, 1KB, some variable number of KB, but always corrupt. I have tried python's terminate(), kill(), as well as process.send_signal(signal.CTRL_C_EVENT), all in conjunction with combinations of join() and wait() to ensure the process is completed. I have also used both processes and process groups, and threading. Has anyone else run into this issue, and if you solved it, how?

rom1v commented 2 weeks ago

5195

Mindputty commented 2 weeks ago

@rom1v Thank you for the quick reply! I tried os.kill(pid, signal.SIGINT), but that isn't working. When using os.kill(pid, signal.CTRL_C_EVENT), it hangs indefinitely because I'm using join().

The strange thing is, although my script is supposed to open and close (and save) recordings 6 times during its execution, they all stay open. When the script terminates, they are all closed at that point and are saved correctly (!). Could it be that the script is cleaning up in a way that any individual call for close/terminate/kill is not doing properly? What signal does scrcpy need to terminate gracefully?

EDIT: I am on a Windows 10 machine, using scrcpy 1.24 (I also tried with 2.7 without success).