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

Fix: the server stopped when requesting the maximum integer value(2147483647) for 'videoBitRate' #4930

Closed

Conversation

kyoung-mo-yang
Copy link

@kyoung-mo-yang kyoung-mo-yang commented May 16, 2024

If the value of --video-bit-rate exceeds the supported range, the server is stopped.

$> scrcpy -s R59N102E8HT --video-bit-rate=2147483647 
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  R59N102E8HT                     device  SM_A305N
x/server/scrcpy-server: 1 file pushed, 0 skipped. 28.9 MB/s (69343 bytes in 0.002s)
[server] INFO: Device: [samsung] samsung SM-A305N (Android 11)
INFO: Renderer: metal
INFO: Texture: 1080x2336
WARN: Device disconnected
Aborted 

I have added exception handling code for this issue.

@kyoung-mo-yang kyoung-mo-yang changed the title Fix: the server crashes when requesting the maximum integer value(2147483647) for 'videoBitRate' Fix: the server crash when requesting the maximum integer value(2147483647) for 'videoBitRate' May 16, 2024
@@ -48,11 +49,34 @@ public SurfaceEncoder(SurfaceCapture capture, Streamer streamer, int videoBitRat
this.downsizeOnError = downsizeOnError;
}

/**
* Fixing the issue that the server crashes when requesting the maximum integer value(2147483647) for 'videoBitRate'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it "crash" (like a segfault) or just throw an exception printed in the console?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The program did not terminate abnormally due to a segmentation fault; instead, it exited with an 'aborted' log message.

String mimeType = format.getString(MediaFormat.KEY_MIME);
if (mimeType != null) {
MediaCodecInfo mediaCodecInfo = mediaCodec.getCodecInfo();
Range<Integer> bitrateRange = mediaCodecInfo.getCapabilitiesForType(mimeType).getVideoCapabilities().getBitrateRange();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, it would be better to check all video capabilities like you are doing there.

But in the past, I noticed that in practice (on some devices), the reported values were not always accurate (especially for sizes), where "valid" values don't work or "invalid" values works. That's why I don't use them to filter parameters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mentioned, if there are cases where the attribute values provided by the equipment are invalid, a comprehensive test of the entire equipment (within a specific range) will be required.

@kyoung-mo-yang kyoung-mo-yang changed the title Fix: the server crash when requesting the maximum integer value(2147483647) for 'videoBitRate' Fix: the server stopped when requesting the maximum integer value(2147483647) for 'videoBitRate' May 28, 2024
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.

None yet

2 participants