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

Performance Optimization Needed for Modified scrcpy Project #4913

Closed
muyiraolong opened this issue May 9, 2024 · 1 comment
Closed

Performance Optimization Needed for Modified scrcpy Project #4913

muyiraolong opened this issue May 9, 2024 · 1 comment

Comments

@muyiraolong
Copy link

muyiraolong commented May 9, 2024

I have modified the scrcpy project to record mobile device behavior, convert the resulting video into images, and name these images based on the system timestamp displayed on the device. While I achieve good results on devices with powerful CPUs (with a timestamp discrepancy of less than 5ms compared to a trace), I encounter significant performance issues and high latency (with a timestamp discrepancy of over 15ms compared to a trace) on devices with less capable CPUs.

As I am working on a project where performance overhead is crucial, I would like to seek advice on potential optimizations that I could implement in the source code and instructions. Specifically, I'm wondering:

  1. What areas of the scrcpy codebase should I focus on for improving performance, especially on lower-end devices?

  2. Are there any known optimizations or techniques that could reduce the delay between capturing the screen and processing the resulting image?

I appreciate any guidance or suggestions that the community may have in addressing these performance challenges. Your assistance in this matter would be greatly appreciated. Thank you for considering my inquiry and for your time.

@rom1v
Copy link
Collaborator

rom1v commented May 10, 2024

The timestamps of captured frames are provided directly by MediaCodec with the encoded packet:

streamer.writePacket(codecBuffer, bufferInfo);

long pts = bufferInfo.presentationTimeUs;

This is (or should be) the capture time, not the time where you retrieve the encoded frame, so if you check the current time when MediaCodec provides a frame, it's a bit later, depending on your device/encoder, so it's expected that a trace would be "delayed" compared to the capture time. Maybe you should subtract the duration between the capture time and the current time immediately after the MediaCodec call returns if you want to compare with your own timestamped traces.

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