scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Using ^C to stop mp4 recording corrupts file (windows)

Open evillurker opened this issue 1 year ago • 23 comments

  • OS: [Windows.]
  • Scrcpy version: [2.7]
  • Installation method: [windows release]
  • Device model: [Galaxy S23]
  • Android version: [14]

Describe the bug

When finishing with ^C recording, it says it completed but the file is corrupt when choosing mp4 method. mkv doesn't produce this bug but it produces jagged quality in the first few seconds. I tried using adb to kill the process but it keeps recording when trying to do that. Corruption not always occurs but around 50% of the time

evillurker avatar Oct 12 '24 13:10 evillurker

Do you use "Windows Terminal"? https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2265289619

I tried using adb to kill the process but it keeps recording when trying to do that.

That's should not be possible. if you kill adb, then scrcpy terminates, and this terminates the recording.

Please post a whole console output when you kill adb (also include the command you executed).

Does it work correctly when you close the scrcpy window (not the terminal)?

rom1v avatar Oct 12 '24 13:10 rom1v

Nevermind, seems like all I had to do is taskkill adb.exe

evillurker avatar Oct 12 '24 14:10 evillurker

But the best is to close the scrcpy window.

Ctrl+c should also work in theory, but not with Windows terminal for some reason.

rom1v avatar Oct 12 '24 14:10 rom1v

Ctrl C in the console window works 50% of the time, the other 50% in windows it corrupts the header of the mp4. I am waiting for the --time-limit on your next version, until then I have to make my own GUI to stop recording

evillurker avatar Oct 12 '24 15:10 evillurker

Ctrl+c should also work in theory, but not with Windows terminal for some reason.

Ctrl C in the console window works 50% of the time

When I say that it does not work, I mean that it abruptly kills the process (which is never ok), instead of sending the equivalent of SIGINT so that the process terminates gracefully and scrcpy can finish running properly.

rom1v avatar Oct 12 '24 15:10 rom1v

I am waiting for the --time-limit on your next version

You can use the binary from #5370, it includes the time-limit fix (afbaf59abba79a79ab6f4c659ff3d832e02a8e7f).

rom1v avatar Oct 12 '24 15:10 rom1v

I am waiting for the --time-limit on your next version

You can use the binary from #5370, it includes the time-limit fix (afbaf59).

Thank you, I didn't know I can download it. This will be very useful.

evillurker avatar Oct 12 '24 15:10 evillurker

Please also test interrupting using Ctrl+c with this version: https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2408888597

That will help to fix the problem.

rom1v avatar Oct 13 '24 11:10 rom1v

Ctrl C does not always work, I try using it and sometimes it reacts, sometimes it just keeps recording until i manually close the window. Last time I closed the window the file was corrupted. But the time--limit works perfectly.

evillurker avatar Oct 13 '24 11:10 evillurker

Ctrl C does not always work

Even with the version I published this morning here? https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2408888597 (on that version, time-limit will still be broken though)

rom1v avatar Oct 13 '24 11:10 rom1v

I am waiting for the --time-limit on your next version

You can use the binary from #5370, it includes the time-limit fix (afbaf59).

With this version

evillurker avatar Oct 13 '24 11:10 evillurker

With this version

No, as a test to fix recording interruption on Windows, I'd like you to test https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2408888597 please.

rom1v avatar Oct 13 '24 11:10 rom1v

Ok i'll give it a test soon when I'm done recording some stuff that needs time-limit

evillurker avatar Oct 13 '24 12:10 evillurker

As of now after testing, ^C works fine when directly running scrcpy.exe, but still corrupts if used in console window through cmd.exe sometimes. So basically it needs to be directly running and not through a cmd window for some reason.

evillurker avatar Oct 14 '24 08:10 evillurker

Thank you for your tests. Is your terminal "Windows terminal" (like in the videos in https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2242503206), or the old default console (https://github.com/Genymobile/scrcpy/issues/5122#issuecomment-2265153630)?

rom1v avatar Oct 14 '24 08:10 rom1v

It's not Windows Terminal, it's cmd.exe image

evillurker avatar Oct 14 '24 08:10 evillurker

OK. Do you get the line Recording complete to mp4 file: file.mp4 at the end when you press Ctrl+c after running scrcpy --record=file.mp4?

rom1v avatar Oct 14 '24 08:10 rom1v

Yes, I get that line, but 50% of the time (maybe more) its corrupted, unplayable Does not happen with mkv however the mkv has jagged/scrambled display on the first few seconds.

evillurker avatar Oct 14 '24 09:10 evillurker

Yes, I get that line

Oh ok, that's a different problem then.

Could you please post such a corrupted file?

rom1v avatar Oct 14 '24 09:10 rom1v

Sure, I'll post one when I get home tonight.

evillurker avatar Oct 14 '24 09:10 evillurker

https://github.com/user-attachments/assets/2ef66425-dc4b-4d06-bd04-983a723a6c40

evillurker avatar Oct 15 '24 18:10 evillurker

OK, that's very strange if Recording complete to mp4 file: file.mp4 is correctly printed.

Can you reproduce the problem if you close the scrcpy window?

rom1v avatar Oct 15 '24 19:10 rom1v

It depends on if I run it through cmd or directly through the .exe What do you want to test? Maybe just contact me on discord so we can test it live, if you want. EvilLurker

evillurker avatar Oct 16 '24 03:10 evillurker

I am using it on Mac, and the file is always corrupt if I record a long video. The short video is fine.

mjzhaochenyi avatar Jan 08 '25 06:01 mjzhaochenyi

How do you stop recording on your mac? DO NOT close the console (i.e. do not abruptly kill the app), but either close the scrcpy window or Ctrl+c in the console.

rom1v avatar Jan 08 '25 06:01 rom1v

How do you stop recording on your mac? DO NOT close the console (i.e. do not abruptly kill the app), but either close the scrcpy window or Ctrl+c in the console.

I tried "close app window" and "ctrl+c", but the results were the same. My long videos are normally 3 hours sessions.

mjzhaochenyi avatar Jan 08 '25 06:01 mjzhaochenyi

What's the output in the console when you close scrcpy? (in particular the log about recording)

rom1v avatar Jan 08 '25 06:01 rom1v