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

Added Save Screenshot #2040

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

Spudmn
Copy link

@Spudmn Spudmn commented Jan 16, 2021

Pressing the MOD + Q key will save a screenshot the next time the screen is rendered.

It saves a PNG file with a date time stamp filename.

It uses lodepng to encode the file. Thanks Lode Vandevenne (https://github.com/lvandeve/lodepng)

The save_screenshot function has been modified from user1902824 (https://stackoverflow.com/questions/34255820/save-sdl-texture-to-file)

Limitations.

If 2 screenshots are taken within the same second, the file name will be the same and the first file will be overwritten

Does not handle client side screen rotation.

Pressing the MOD + Q key will save a screenshot the next time the screen is rendered.

It saves a PNG file with a date time stamp filename.

It uses lodepng to encode the file.  Thanks Lode Vandevenne (https://github.com/lvandeve/lodepng)

The save_screenshot function has been modified from user1902824 (https://stackoverflow.com/questions/34255820/save-sdl-texture-to-file)

Limitations.

If 2 screenshots are taken within the same second, the file name will be the same and the first file will be overwritten

Does not handle client side screen rotation.
@rom1v
Copy link
Collaborator

rom1v commented Jan 16, 2021

Thank you for working on this. This is a feature often requested (#684), and it is not trivial.

will save a screenshot the next time the screen is rendered.

Why not the current frame immediately? (if the screen content does not change, the next frame could be sent seconds or minutes later in theory)

I have several general remarks.

This PR adds a dependency (lodepng). Scrcpy already depends on FFmpeg, which can encode images, so I'd prefer to use FFmpeg. This is far less straightforward, but this avoids a separate image encoder (I have pending work for decoding images too). Btw, since the input picture is already compressed (it comes from a H.264 stream), it would be better to save it to JPG than PNG (lossless is unnecessary on a lossy input).

Also, encoding a picture takes time: it should not be done on the UI thread, but on a separate thread.

I think that it would be more straightforward to encode the content of the decoded frame (the rendering frame in struct video_buffer, which would need to be refcounted), rather than to retrieve the SDL texture content (moreover, it's in YUV, which is the native JPEG format). Even semantically, in theory we could want to capture a screenshot even if we don't display the frame on screen.

Regards

@JASHIKO
Copy link

JASHIKO commented Feb 15, 2021

Also came here to add that instant screenshot would be amazing to add. It's probably the only feature missing from this amazing program at the moment.

@ghost
Copy link

ghost commented Apr 27, 2021

If I press a key mod + Q, it doesn't take a screenshot. What could be the reason? My version: scrcpy v1.17 on Jan 2.

@npes87184
Copy link
Contributor

If I press a key mod + Q, it doesn't take a screenshot. What could be the reason? My version: scrcpy v1.17 on Jan 2.

This PR has not been merged. You can build scrcpy based on this PR manually to include this feature.

@ghost
Copy link

ghost commented May 17, 2021

Can you help me with how I can do it? I'd be grateful for.

@Spudmn
Copy link
Author

Spudmn commented May 17, 2021

Can you help me with how I can do it? I'd be grateful for.

You will need to build scrcpy from my PR.
If you like you can build it from my fork here https://github.com/Spudmn/scrcpy/tree/Added_Save_Screenshot
Please note that I do not have time to maintain this fork. It worked for what I needed, maybe it will work for you.

@mamatagelanee07
Copy link

This could be a convenient solution so don't have to go through different commands for screenshots.

@YerongLi
Copy link

If I press a key mod + Q, it doesn't take a screenshot. What could be the reason? My version: scrcpy v1.17 on Jan 2.

This PR has not been merged. You can build scrcpy based on this PR manually to include this feature.

How we can build with this PR?

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

Successfully merging this pull request may close these issues.

6 participants