-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Change capture FPS #488
Comments
I already tried some time ago, by requesting a specific FPS here, but it has no effect: the encoder takes one frame on every surface update (it's not a constant FPS). |
This would be an awesome feature, especially for over wifi capture. Slowing down to even lower fps would be great. |
This is supported since Android Q ( diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
index 52f6f26..a55e84a 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
@@ -6,6 +6,7 @@ import android.graphics.Rect;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
+import android.os.Build;
import android.os.IBinder;
import android.os.Looper;
import android.view.Surface;
@@ -157,6 +158,9 @@ public class ScreenEncoder implements Device.RotationListener {
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval);
// display the very first frame, and recover from bad quality when no new frames
format.setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, MICROSECONDS_IN_ONE_SECOND * REPEAT_FRAME_DELAY / frameRate); // µs
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ format.setFloat(MediaFormat.KEY_MAX_FPS_TO_ENCODER, 10f);
+ }
return format;
} |
🤯 Thank you! Works perfectly, exactly what I was looking for. |
Add an option to limit the capture frame rate. It only works for devices with Android >= 10. Fixes <#488>
Implemented |
I've tried to set KEY_MAX_FPS_TO_ENCODER in AndroidO(Samsung Galalxy S7) and P(Samsung Galalxy S8+), they all could work. Actually, this key was available since O, they make it public until Android10. |
KEY_MAX_FPS_TO_ENCODER existed privately before Android 10: <#488 (comment)>
KEY_MAX_FPS_TO_ENCODER existed privately before Android 10: <#488 (comment)>
Hi, thank you for this amazing tool. I use it for livestreaming mobile games. I do not have a high-end computer, so frames are skipped, but fps stays around 55-60. I stream at 30fps, so capping the output at 30fps would eliminate frame drop and improve the smoothness of my stream. I am on Android 9 (OnePlus 7 Pro). I saw your commit with the added max-fps command for Android <10. I do not know how to compile the program, however. I use your pre-built archive, but I would like this option. Do I need to learn how and recompile the program, or could you upload a modified executable/server with this option? My archive already contains all dependencies, as with all of your prebuilt archives. Thank you. |
Sorry, I can't for now (holidays...). |
Thanks for your quick reply. It would be quite the effort and time for me to teach myself to build the program, even with your excellent instructions. I don't have much experience with any of that. I hope you have a great holiday! Do you intend to implement these changes in a new version sometime soon (in the new year)? I hope so. If I could donate even a few dollars to support your efforts and your project, I would also like to do that. I know you've put a lot of work into this. Again, happy holidays, and thank you for all your hard work! |
|
Awesome, thank you! I just had an update come in that brought me to Android 10, though. I have a secondary device that I use sometimes that is on Android 9, so I will install this too. Thanks! I hope you had a good holiday! |
@shiwf @vegaskukichyo Released in v1.13. |
Could you add a command line to change the capture fps (i.e. to 30fps)? I believe it is locked/capped at 60fps at the moment.
The text was updated successfully, but these errors were encountered: