Sitelet https://github.com/SharpAdb/AdvancedSharpAdbClient/issues/23
Skip to content

Can Screen Capture be improved? #23

Description

@vuduong1124

Describe your feature request

Is it possible to capture screen devices faster?Feature title

static async void Main(string[] args)
{
    ...
    System.Drawing.Image img = client.GetFrameBufferAsync(device, CancellationToken.None).GetAwaiter().GetResult();
    ...
}

Specifically, it currently takes 180 ~ 200ms for 1 screen capture

How important is this to you?

Nice-to-have

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. phuongbk90 commented on May 31, 2023

    @phuongbk90

    hi @vuduong1124
    Can you share block code to convert FrameBuffer to image
    It seems this tutorial is not correct
    System.Drawing.Image img = client.GetFrameBufferAsync(device, CancellationToken.None).GetAwaiter().GetResult();

  2. jensbrak commented on Jun 16, 2023

    @jensbrak

    It seems this tutorial is not correct

    (Well, I just tried this library out, I have been using python and an adb library for python before but wanted to give this library a shot).

    About the tutorial not being correct, I assume you're reffering to the examples and that you get an error that FrameBuffer can't be made into an Image? There's an explicit conversion implemented (there seems to be other conversions too , depending on need, not only Image).

    You can do either of this to get around this problem and make the compiler happy:

    Image image = (Image) client.GetFrameBufferAsync(device, CancellationToken.None).GetAwaiter().GetResult();

    or

    Image image = client.GetFrameBufferAsync(device, CancellationToken.None).GetAwaiter().GetResult().ToImage();

    This will, in theory, make it work - I assume this is the intended way to do it.

    However, I get an exception when I execute the above code, trying to grab a screenshot (from a device with verified working ADB connection). The Framebuffer gets disposed at some point and the library throws exception about. I haven't tested much so I might as well mention it.

    I can see in the source code of the library where it does this but I haven't tried to understand why this happen. Also noted that there's no unit test implemented for GetFrameBufferAsync so maybe the error is actually a bug not being detected. But honestly, I don't know. (Actually, this is why I ended up here, to see if anyone else have mentioned this exception or if created an issue ticket for it.)

  3. wherewhere commented on Jun 17, 2023

    @wherewhere
    Member
  4. jensbrak commented on Jun 18, 2023

    @jensbrak

    fa1087f

    Nice one! Started diggin into the workings and realized there were plenty of stuff probably missing. Interesting to see what it actually was. Great work!

  5. phuongbk90 commented on Jul 10, 2023

    @phuongbk90

    fa1087f

    It is good, Do you have plan to include this commit in release version.

  6. wherewhere commented on Jul 10, 2023

    @wherewhere
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions