mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-09-02 15:45:42 +00:00
Add bit-rate command-line option
Add a command-line option (-b/--bit-rate) to customize the video bit-rate.
This commit is contained in:
parent
7fe7bbf58c
commit
6b546a87ab
8 changed files with 79 additions and 15 deletions
|
@ -2,6 +2,7 @@ package com.genymobile.scrcpy;
|
|||
|
||||
public class Options {
|
||||
private int maxSize;
|
||||
private int bitRate;
|
||||
|
||||
public int getMaxSize() {
|
||||
return maxSize;
|
||||
|
@ -10,4 +11,12 @@ public class Options {
|
|||
public void setMaxSize(int maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
|
||||
public int getBitRate() {
|
||||
return bitRate;
|
||||
}
|
||||
|
||||
public void setBitRate(int bitRate) {
|
||||
this.bitRate = bitRate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ public class ScrCpyServer {
|
|||
private static void scrcpy(Options options) throws IOException {
|
||||
final Device device = new Device(options);
|
||||
try (DesktopConnection connection = DesktopConnection.open(device)) {
|
||||
ScreenEncoder screenEncoder = new ScreenEncoder();
|
||||
ScreenEncoder screenEncoder = new ScreenEncoder(options.getBitRate());
|
||||
|
||||
// asynchronous
|
||||
startEventController(device, connection);
|
||||
|
@ -36,10 +36,18 @@ public class ScrCpyServer {
|
|||
|
||||
private static Options createOptions(String... args) {
|
||||
Options options = new Options();
|
||||
if (args.length > 0) {
|
||||
int maxSize = Integer.parseInt(args[0]) & ~7; // multiple of 8
|
||||
options.setMaxSize(maxSize);
|
||||
if (args.length < 1) {
|
||||
return options;
|
||||
}
|
||||
int maxSize = Integer.parseInt(args[0]) & ~7; // multiple of 8
|
||||
options.setMaxSize(maxSize);
|
||||
|
||||
if (args.length < 2) {
|
||||
return options;
|
||||
}
|
||||
int bitRate = Integer.parseInt(args[1]);
|
||||
options.setBitRate(bitRate);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||
this.iFrameInterval = iFrameInterval;
|
||||
}
|
||||
|
||||
public ScreenEncoder(int bitRate) {
|
||||
this(bitRate, DEFAULT_FRAME_RATE, DEFAULT_I_FRAME_INTERVAL);
|
||||
}
|
||||
|
||||
public ScreenEncoder() {
|
||||
this(DEFAULT_BIT_RATE, DEFAULT_FRAME_RATE, DEFAULT_I_FRAME_INTERVAL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue