-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
recorded video is corrupted #5122
Comments
If you kill the process abruptly, the muxer will never have a chance to write the footer, so your mp4 will be corrupted. Although it would still be incorrect for Matroska files (mkv), the resulting files should still be playable). You must send Ctrl+C on Windows instead to interrupt (and never close the cmd console by clicking the |
Can we save the currently recorded video when an exception occurs, such as exiting? That should solve the problem |
The problem lies in saving the video correctly. Currently, I can obtain a playable video only by manually closing the scrcpy application using the X button. However, if I hide the scrcpy window using the --no-window option, I have to terminate the scrcpy processes either by their PID or by using Ctrl+C, both of which result in a corrupted video. |
Using Ctrl+C from the terminal should work correctly, without corrupting video. If it does not (I cannot test currently), this is a bug. If so, please test v2.4 (before |
it seems there is issue with <cntrl+c> itself, here are the reference videos that could help analyze. tested with version 2.5 : v2.5.webm You can observe there is no info saying recording complete if i terminate by clicking <cntr+c> in the console, but it showed if i close by clicking close button. |
Could you please test with scrcpy v2.0, which uses an older SDL version? |
i tried with version 2.0. but the results are same. here are the logs, you can see first time i terminated with <cntrl+c> and second one i terminated with close button. C:\Users\sanji\poc\Videos>scrcpy --record=video1_v2.mp4
C:\Users\sanji\poc\Videos>scrcpy --record=video2_v2.mp4 you can observer, if i do <cntrl+c> i'm not getting these "INFO: Recording complete to mp4 file: video2_v2.mp4 |
OK, I can't explain why Ctrl+c does not work as expected on your machine. Scrcpy explicitly catches Ctrl+c on Windows: Line 149 in bbfac9a
Maybe a cmd.exe configuration or something? |
Thank you @rom1v for your help and quick responses to my comments. I appreciate your time and support. I'll try to figure out the issue. |
Interesting. I don't know why. I re-tested, for me it works as expected, I have |
It you run
then Ctrl+c, what's the full output? |
C:\Users\I5343\Pictures>scrcpy -Vverbose --no-window --record=file.mp4
i have attached reference video also, with and without --no-window command |
Thank you. I guess this is the same with the Windows release (instead of the chocolatey package)? Something probably intercepts Ctrl+c at the system level and kills the process. Any antivirus/firewall/something enabled? |
Is it powershell or cmd? |
hello, i have a temporary solution for this, i tried killing process gracefully, it worked. I'm dropping the code below, this might be helpful. code: "@echo off 1: save the file with .bat extension. reference video: *Note: if you use "--no-window", recorded video will be corrupted. |
cmd |
yes, in both the ways i tried installing scrcpy, same results. |
What's your terminal? When I run cmd.exe, it does not look like this at all. Try with |
strange!, i use normal command prompt only (cmd) |
i tried this also 1: Win+r : cmd.exe. but there was no betterment. |
Non only, this terminal is also "limited" (it cannot be resized for example), but above all it probably correctly sends Ctrl+c to the running process. |
vid.webm |
OK, I don't know Windows very well, but IMO the behavior of Ctrl+c is definitely handled differently in your "terminal" app (whichever it is). EDIT: I guess your app is Windows Terminal: https://apps.microsoft.com/detail/9n0dx20hk701 |
yes, but you can see in the above video, i tried opening a new cmd tab from windows terminal and ran the given command. |
If you manage to start the "old" cmd terminal (not just cmd.exe run in Windows Terminal) in some way and confirm that Ctrl+c works, it might be interesting to report the issue to https://github.com/microsoft/terminal |
As Windows 11 is now widely used, it would be helpful if you could provide a way to start and stop 'scrcpy.exe' directly from the command line interface (CLI) without requiring additional steps. This would ease the process for users. |
Could please test scrcpy 2.7, and execute:
Then interrupt with Ctrl+c. Confirm that the process terminates abruptly without Then, replace diffdiff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 854657fbd..1ad0d1f0d 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -150,6 +150,16 @@ sdl_configure(bool video_playback, bool disable_screensaver) {
if (!ok) {
LOGW("Could not set Ctrl+C handler");
}
+ HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
+ DWORD mode;
+ if (GetConsoleMode(hStdin, &mode)) {
+ mode |= ENABLE_PROCESSED_INPUT;
+ if (!SetConsoleMode(hStdin, mode)) {
+ LOGW("Could not set console mode");
+ }
+ } else {
+ LOGW("Could not get console mode");
+ }
#endif // _WIN32
if (!video_playback) {
And confirm that it works correctly. |
Checked FAQ
Checked open Issues
Environment
OS: Windows 11
Scrcpy version: 2.5
Installation method: Windows release/ through choco
Device model: infix and mia2
Android version: Android 11
Describe the bug
I'm using this scrcpy to record the device screen in mp4 format, but without the floating window(--no-window), and terminating the scrcpy.exe by their PID(taskkill /PID ). if i do this, the recorded video is corrupted. instead if i close by clicking the close button or by killing the process by removing the --no-window flag then i can play the video.
This issue happens only in MS Windows and works fine in Linux.
But i want to record the video without the the window showing and if possible please provide gracefully closing option from cli
here is a code snippet how i used:
issue causing snippet=> exec(
scrcpy --record=video.mp4 --max-fps 15 --max-size 480 --no-window
, (error, _stdout) => {console.log("recording....")
}
working snippet =>
issue causing snippet=> exec(
scrcpy --record=video.mp4 --max-fps 15 --max-size 480
, (error, _stdout) => {console.log("recording....")
}
and here is the code how i find PIDs and killing them =>
The text was updated successfully, but these errors were encountered: