scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Hotkeys for record screen

Open fleytman opened this issue 6 years ago • 7 comments

To record a video I need to run the command: scrcpy -r file.mkv This method is inconvenient if the scrcpy is already running and I need to make a video. I will have to return to the console, close the program, enter the command. After recording the video, I will have to close the scrcpy and reopen it without parameters.

I would like to be able to manage the recording of video from the scrcpy, namely

  1. Start recording
  2. Pause recording
  3. Stop recording

For this, I can use third-party software as OBS, but when I test mobile applications in the scrcpy, switching to between different windows is distracting.

fleytman avatar Mar 25 '19 14:03 fleytman

The problem for this is UX: how do you pass the filename when you record at any time (possibly several times per session)?

rom1v avatar Mar 25 '19 14:03 rom1v

I think you should not ask the user to manually set the file name. It can be automatically generated. For example: "Scrcpy screen record 2019-03-25 at 7.30.40.mkv" I think we should add a new parameter to specify the directory for recorded videos. For example: scrcpy --record-dir ~/android_videos

fleytman avatar Mar 25 '19 14:03 fleytman

Any news regarding this request?

Zero3K avatar Mar 01 '20 03:03 Zero3K

Ref: https://github.com/Genymobile/scrcpy/issues/1186#issuecomment-592386916

Recording may only start on new keyframe (it may not just be "passive", record where you are). To start recording in the middle of the stream, the client must request to the device to generate a new keyframe (typically, just restart the encoding like on device rotation), then ignore all frames received before that keyframe (+ the config packet).

rom1v avatar Apr 09 '20 20:04 rom1v

I understand correctly that this method will solve the problem? Should we expect a feature?

fleytman avatar Feb 08 '21 12:02 fleytman

Would be nice!

Fusseldieb avatar Jul 07 '21 16:07 Fusseldieb

the client must request to the device to generate a new keyframe (typically, just restart the encoding like on device rotation)

Now we have the requestReset method, it should be easier to add a "restart encoding" command?

https://github.com/Genymobile/scrcpy/blob/665ccb32f5306ebd866dc0d99f4d08ed2aeb91c3/server/src/main/java/com/genymobile/scrcpy/video/SurfaceCapture.java#L21

I had experimented it in my internal fork, it works very well, and doesn't affect mirroring at all.

Another use case I got from a developer is streaming the video to multiple clients (using Scrcpy server and a custom client), without such command, newly connected clients won't have a keyframe to start decoding so there will be several seconds of corrupted image.

how do you pass the filename when you record at any time (possibly several times per session)

SDL3 added an API to open a save dialog, so when stopping recording we can ask the user where to save (or discard) it. But it doesn't exist in SDL2, so I think saving to a user specified folder with auto-generated file names is also ok.

yume-chan avatar Sep 26 '24 12:09 yume-chan