Skip to content
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

What is the best option for scrcpy to get screenshot of device every 200ms or 500ms? #3345

Closed
S-YOU opened this issue Jun 22, 2022 · 5 comments

Comments

@S-YOU
Copy link

S-YOU commented Jun 22, 2022

  • I'm currently using screencapture on my Mac, but looking for native options from scrcpy.
  • adb exec-out screencap took 1.5s on my environment so it is not the option
@rom1v
Copy link
Collaborator

rom1v commented Jun 22, 2022

There is no "screenshot" feature implemented/merged (see #2040 #684).

However, if you want a "screenshot" every 200ms, you could record a video at 5 fps:

scrcpy --fps=5 --record=video.mkv

(then convert the video to images using ffmpeg)

@S-YOU
Copy link
Author

S-YOU commented Jun 22, 2022

Thank you very much for the information and the hint, --fps option would reduce the file pretty much.

@S-YOU
Copy link
Author

S-YOU commented Jun 22, 2022

--fps you meant is --max-fps? I somehow seeing that --max-fps=1 or 2 still seeing output of 7~10 fps with --print-fps option.

EDIT: I am seeing 19.92 fps with --max-fps 1 , is there a way to limit it somehow?

  Metadata:
    COMMENT         : Recorded by scrcpy 1.24
    ENCODER         : Lavf59.16.100
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuv420p(progressive), 1024x456, 19.92 tbr, 1k tbn

@rom1v
Copy link
Collaborator

rom1v commented Jun 22, 2022

--fps you meant is --max-fps?

Yes, sorry, --max-fps.

I somehow seeing that --max-fps=1 or 2 still seeing output of 7~10 fps with --print-fps option.

Indeed, that's surprising.

But in fact, it's due to KEY_REPEAT_PREVIOUS_FRAME_AFTER (here), which repeats a frame (after 100ms as configured) when no new frame is produced, to recover from possibly bad quality on a static frame. It's not entirely clear to me why it's does not always produce 10fps then, but maybe it avoids a new frame if it brings no changed compared to the previous encoded+decoded one.

You could disable this option by overriding the MediaCodec option:

scrcpy --max-fps=2 --print-fps --codec-options=repeat-previous-frame-after:long=0

You will not get more than 2 fps (sometimes 3 due to how it's measured by intervals on the client side, but never more).

I am seeing 19.92 fps with --max-fps 1 , is there a way to limit it somehow?

The framerate is variable, and typically badly calculated by ffmpeg when it lists the file properties.

@S-YOU
Copy link
Author

S-YOU commented Jun 23, 2022

scrcpy --max-fps=2 --print-fps --codec-options=repeat-previous-frame-after:string=0

Thank you very much, that worked!

Also, I've hacked into decoder.c and figured a quick and dirty way to dump screenshots directly there.
You may close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants