mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 05:24:19 +01:00
Add --angle
Add an option to rotate the video content by a custom angle. Fixes #4135 <https://github.com/Genymobile/scrcpy/issues/4135> Fixes #4345 <https://github.com/Genymobile/scrcpy/issues/4345> Refs #4658 <https://github.com/Genymobile/scrcpy/pull/4658> PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
This commit is contained in:
@@ -34,6 +34,7 @@ public class Options {
|
||||
private int videoBitRate = 8000000;
|
||||
private int audioBitRate = 128000;
|
||||
private float maxFps;
|
||||
private float angle;
|
||||
private boolean tunnelForward;
|
||||
private Rect crop;
|
||||
private boolean control = true;
|
||||
@@ -127,6 +128,10 @@ public class Options {
|
||||
return maxFps;
|
||||
}
|
||||
|
||||
public float getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public boolean isTunnelForward() {
|
||||
return tunnelForward;
|
||||
}
|
||||
@@ -349,6 +354,9 @@ public class Options {
|
||||
case "max_fps":
|
||||
options.maxFps = parseFloat("max_fps", value);
|
||||
break;
|
||||
case "angle":
|
||||
options.angle = parseFloat("angle", value);
|
||||
break;
|
||||
case "tunnel_forward":
|
||||
options.tunnelForward = Boolean.parseBoolean(value);
|
||||
break;
|
||||
|
||||
@@ -62,6 +62,7 @@ public class CameraCapture extends SurfaceCapture {
|
||||
private final boolean highSpeed;
|
||||
private final Rect crop;
|
||||
private final Orientation captureOrientation;
|
||||
private final float angle;
|
||||
|
||||
private String cameraId;
|
||||
private Size captureSize;
|
||||
@@ -88,6 +89,7 @@ public class CameraCapture extends SurfaceCapture {
|
||||
this.crop = options.getCrop();
|
||||
this.captureOrientation = options.getCaptureOrientation();
|
||||
assert captureOrientation != null;
|
||||
this.angle = options.getAngle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +133,8 @@ public class CameraCapture extends SurfaceCapture {
|
||||
filter.addOrientation(captureOrientation);
|
||||
}
|
||||
|
||||
filter.addAngle(angle);
|
||||
|
||||
transform = filter.getInverseTransform();
|
||||
videoSize = filter.getOutputSize().limit(maxSize).round8();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class NewDisplayCapture extends SurfaceCapture {
|
||||
private final Rect crop;
|
||||
private final boolean captureOrientationLocked;
|
||||
private final Orientation captureOrientation;
|
||||
private final float angle;
|
||||
|
||||
private VirtualDisplay virtualDisplay;
|
||||
private Size videoSize;
|
||||
@@ -70,6 +71,7 @@ public class NewDisplayCapture extends SurfaceCapture {
|
||||
this.captureOrientationLocked = options.getCaptureOrientationLock() != Orientation.Lock.Unlocked;
|
||||
this.captureOrientation = options.getCaptureOrientation();
|
||||
assert captureOrientation != null;
|
||||
this.angle = options.getAngle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,6 +124,7 @@ public class NewDisplayCapture extends SurfaceCapture {
|
||||
}
|
||||
|
||||
filter.addOrientation(displayRotation, captureOrientationLocked, captureOrientation);
|
||||
filter.addAngle(angle);
|
||||
|
||||
eventTransform = filter.getInverseTransform();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class ScreenCapture extends SurfaceCapture {
|
||||
private final Rect crop;
|
||||
private Orientation.Lock captureOrientationLock;
|
||||
private Orientation captureOrientation;
|
||||
private final float angle;
|
||||
|
||||
private DisplayInfo displayInfo;
|
||||
private Size videoSize;
|
||||
@@ -55,6 +56,7 @@ public class ScreenCapture extends SurfaceCapture {
|
||||
this.captureOrientation = options.getCaptureOrientation();
|
||||
assert captureOrientationLock != null;
|
||||
assert captureOrientation != null;
|
||||
this.angle = options.getAngle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,6 +94,7 @@ public class ScreenCapture extends SurfaceCapture {
|
||||
|
||||
boolean locked = captureOrientationLock != Orientation.Lock.Unlocked;
|
||||
filter.addOrientation(displayInfo.getRotation(), locked, captureOrientation);
|
||||
filter.addAngle(angle);
|
||||
|
||||
transform = filter.getInverseTransform();
|
||||
videoSize = filter.getOutputSize().limit(maxSize).round8();
|
||||
|
||||
@@ -95,4 +95,12 @@ public class VideoFilter {
|
||||
}
|
||||
addOrientation(captureOrientation);
|
||||
}
|
||||
|
||||
public void addAngle(double cwAngle) {
|
||||
if (cwAngle == 0) {
|
||||
return;
|
||||
}
|
||||
double ccwAngle = -cwAngle;
|
||||
transform = AffineMatrix.rotate(ccwAngle).withAspectRatio(size).fromCenter().multiply(transform);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user