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

Allow client to take a screenshot #112

Closed
skorokithakis opened this issue Apr 3, 2018 · 11 comments
Closed

Allow client to take a screenshot #112

skorokithakis opened this issue Apr 3, 2018 · 11 comments

Comments

@skorokithakis
Copy link

Would it be possible to add a command-line argument to allow the client to take a screenshot? I am writing a short script to capture the screen, but it's latency-sensitive, and the default way of using screencap takes two full seconds just to encode to JPG. Anything cutting down on that would be very welcome.

@rom1v
Copy link
Collaborator

rom1v commented Apr 3, 2018

Would it be possible to add a command-line argument to allow the client to take a screenshot?

A command-line argument? So it would take a screenshot and exit?

Or a shortcut, to save the current frame to a file somewhere?

@skorokithakis
Copy link
Author

As I need to control it programmatically, it would be most convenient for me if it could take a screenshot and exit, yes. Right now I am looking into whether I can write a small client to speak the protocol and connect to the device to grab a single frame, any information you may have would be of great help.

@rom1v
Copy link
Collaborator

rom1v commented Apr 3, 2018

That would probably not be faster than screencap:

adb exec-out screencap -p > screenshot.png

Starting the java application through app_process is already about 800ms, then the screen would be captured, encoded, transmitted, and saved on the client. If this is faster than screencap, then screencap must be fixed 😄

@skorokithakis
Copy link
Author

Ah, I thought the server would already be running. Yes, you may be right. screencap takes 250ms or so to capture, but 2 sec to convert to png, so it's pretty slow. Feel free to close this ticket, thank you!

@skorokithakis
Copy link
Author

I didn't know about exec-out so I was doing a save-then-pull, exec-out only takes a few ms, thank you!

@rom1v
Copy link
Collaborator

rom1v commented Apr 3, 2018

I thought the server would already be running.

Ah ok :)

To be faster, scrcpy could be running, and receive (from whatever channel) a request to take a screenshot, it already has the frame, so it would encode/save it locally (on the computer, which is probably faster than the device to encode a png).

Too specific though.

@skorokithakis
Copy link
Author

Yeah, too specific and screencap is already fast enough with the exec-out trick.

Thanks for the help and for a fantastic project!

@ooing
Copy link

ooing commented Mar 18, 2019

@skorokithakis but I need 2 second

@dedosmedia
Copy link
Contributor

To be faster, scrcpy could be running, and receive (from whatever channel) a request to take a screenshot, it already has the frame, so it would encode/save it locally (on the computer, which is probably faster than the device to encode a png).

Any hint how could I achieve this? I am interested in to develop such a feature.
I am already saving a bitmap from the SDL window, but the picture quality is not that great, have H.264 artifacts.
What you described on that comment would improve picture quality?

Thanks Romain

@rom1v
Copy link
Collaborator

rom1v commented Aug 31, 2019

@dedosmedia see #684

@mankidal19
Copy link

I thought the server would already be running.

Ah ok :)

To be faster, scrcpy could be running, and receive (from whatever channel) a request to take a screenshot, it already has the frame, so it would encode/save it locally (on the computer, which is probably faster than the device to encode a png).

Too specific though.

Dear @rom1v, thank you for your workaround suggestion. Now I managed to write a simple bash script to automatically execute scrcpy, request screenshot in ubuntu using gnome-screenshot (no window), save it, & close the scrcpy window. The problem is the captured image resolution is not correct as my device (an Android TV) has a 2k resolution. This is because my PC monitor aspect ratio is 16:10 while the TV itself aspect ratio is 16:9. (Already using ctrl + G shortcut). However, the tool I'm developing has a requirement to preserve the original device resolution. Any idea how to solve this? adb screencap doesn't always reliable because it can't capture some screens (especially 3rd party apps i.e., YouTube main screen), which will return an empty png file.

@rom1v rom1v mentioned this issue Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants