Options
Scrcpy protocol changes over time, and are usually not backward compatible. Tango is compatible with many versions of Scrcpy server, by providing a set of options classes for each server version (or range).
The options class serves two purposes:
- It defines which server options are available (for you, the user)
- It normalize the behavior between different server versions (for internal use)
It's important to use the correct options class for the server version you're using. Using an incorrect version almost always results in errors.
If the latest version of Scrcpy server doesn't have a matching options class, the last supported version can be tried. If it doesn't work, you may need to wait for an update.
With @yume-chan/scrcpy
Tango supports all version between 1.15 and 3.1, by providing a set of options classes for each server version.
For example, ScrcpyOptions1_15 is the options class for server version 1.15, ScrcpyOptions1_15_1 for version 1.15.1, and ScrcpyOptions3_1 for version 3.1, and so on.
These options classes are fully tree-shakeable. When using a bundler/minifier, only code related to the version you're using will be included.
All options classes take a single object parameter for server options:
export class ScrcpyOptionsX_YY {
constructor(init: Partial<ScrcpyOptionsX_YY.Init>);
}
import { ScrcpyOptions2_2 } from "@yume-chan/scrcpy";
const options = new ScrcpyOptions2_2({
videoSource: "camera",
// ...
});
Check the TypeScript definition files for available server options in each version.
Some part of the options class is stateful, so reuse an instance between multiple connections is not recommended. Don't do this unless you checked the source code to make sure only the stateless part is being used.
With @yume-chan/adb-scrcpy
@yume-chan/adb-scrcpy needs to do some additional behavior normalizations, so it has its own options classes.
Similar to @yume-chan/scrcpy, there is an option class for each server version. The naming convention is the same as @yume-chan/scrcpy, but with an Adb prefix. For example, AdbScrcpyOptions2_1 is the options class for server version 2.1.
AdbScrcpyOptionsX_YY classes take the same server options parameter, and an optional client options object:
import type { AdbNoneProtocolSpawner } from "@yume-chan/adb";
export interface AdbScrcpyClientOptions {
version?: string;
spawner?: AdbNoneProtocolSpawner | undefined;
}
declare class AdbScrcpyOptionsX_YY extends ScrcpyOptionsX_YY {
constructor(
init: ScrcpyOptions1_15_1.Init,
clientOptions?: AdbScrcpyClientOptions,
);
}
AdbScrcpyClientOptions interface includes:
version: The server version to use. The default value matches the options class name. This option is rarely used, unless you are using a custom server binary with different version string.spawner: A custom process spawner to start the server process. The default value isundefined, which usesadb.subprocess.noneProtocol. This option is rarely used, unless you have a different method (like SSH) to start processes on the device.
- JavaScript
- TypeScript
import { AdbScrcpyOptions2_1 } from "@yume-chan/adb-scrcpy";
const options = new AdbScrcpyOptions2_1({
videoSource: "camera",
// ...
});
import { AdbScrcpyOptions2_1 } from "@yume-chan/adb-scrcpy";
import { ScrcpyOptions2_2 } from "@yume-chan/scrcpy";
const options = new AdbScrcpyOptions2_1({
videoSource: "camera",
// ...
});
List of server options (by version introduced)
v1.15
logLevel: Sets the logging level for the Scrcpy server-
"debug" | "info" | "warn" | "error"(until 1.17) -
"verbose" | "debug" | "info" | "warn" | "error"(since 1.18)
-
maxSize(number): Sets the maximum width and height of the video streammaxFps(number): Sets the maximum frame rate for the video stream in frames per secondlockVideoOrientation: Locks the orientation of the video stream-
"-1 | 0 | 1 | 2 | 3"(until 1.17) -
"-2 | -1 | 0 | 1 | 2 | 3"(since 1.18)
-
tunnelForward(boolean): Use ADB forward tunnel instead of reverse tunnelcrop(string | ScrcpyCrop): Crops the video stream to a specific regionsendFrameMeta(boolean): Send presentation timestamps so that the client may record properlycontrol(boolean): Disables the control socketdisplayId(number): Specifies which display to mirrorshowTouches(boolean): Shows visual feedback for touches on the device screenstayAwake(boolean): Prevents the device from sleeping while screen casting is activecodecOptions: Configures video encoding parameters for the selected codec-
string | ScrcpyCodecOptions(until v1.17) -
Deprecated, use
videoCodecOptionsinstead(since v2.0)
-
bitRate: Sets the video bitrate for the stream in bits per second-
number(until v1.17) -
Deprecated, use
videoBitRateinstead(since v2.0)
-
v1.17
encoderName: Specifies the name of the encoder to use for video encoding-
string(until v1.17) -
Deprecated, use
videoEncoderinstead(since v2.0)
-
v1.18
powerOffOnClose(boolean): Automatically powers off the Android device when the scrcpy connection is closed
v1.21
clipboardAutosync(boolean): Enables or disables automatic synchronization of clipboard content between device and client
v1.22
downsizeOnError(boolean): Controls whether the server should downsize the video resolution when encountering initial encoding errors during startupsendDeviceMeta(boolean): Controls whether the server should send device name and size at the start of the video streamsendDummyByte(boolean): Controls whether the server should send a0byte at the start of the video stream to detect connection issues
v1.23
cleanup(boolean): Controls whether the server should perform cleanup tasks on exit
v1.24
powerOn(boolean): Controls whether the server should power on the device when starting streaming
v2.0
scid(InstanceId | string | undefined): Specifies a session identifier for the Scrcpy server instancevideoCodec("h264" | "h265" | "av1"): Use H.265 or AV1 video codecsvideoBitRate(number): Sets the video bitrate for the stream in bits per secondvideoCodecOptions(CodecOptions | string | undefined): Configures video encoding parameters for the selected video codecvideoEncoder(string | undefined): Specifies the name of the encoder to use for video encodingaudio(boolean): Disables the audio socketaudioCodec: Specifies the audio codec to use by the server-
"raw" | "opus" | "aac"(between v2.0 and v2.2) -
"raw" | "opus" | "aac" | "flac"(since v2.3)
-
audioBitRate(number): Sets the audio bitrate for the stream in bits per secondaudioCodecOptions(CodecOptions | string | undefined): Configures audio encoding parameters for the selected audio codecaudioEncoder(string | undefined): Specifies the name of the encoder to use for audio encodinglistEncoders(boolean): Lists available encoders on the device and exitslistDisplays(boolean): Lists available displays on the device and exitssendCodecMeta(boolean): Controls whether codec metadata should be sent at the start of the video and audio streams
v2.1
audioSource: Selects the audio source for capturing audio from the device-
"output" | "mic"(between v2.1 and v2.5) -
"output" | "mic" | "playback"(between v2.6 and v3.1) -
"output" | "mic" | "playback" | "mic-unprocessed" | "mic-camcorder" | "mic-voice-recognition" | "mic-voice-communication" | "voice-call" | "voice-call-uplink" | "voice-call-downlink" | "voice-performance"(since v3.2)
-
video(boolean): Disables the video socket
v2.2
videoSource("display" | "camera"): Selects the video source for capturing video from the devicecameraId(string | undefined): Specifies the camera ID to use whenvideoSourceis set to"camera"cameraSize(string | undefined): Sets the camera capture size whenvideoSourceis set to"camera"cameraFacing("front" | "back" | "external" | undefined): Specifies which camera facing direction to use whenvideoSourceis set to"camera"cameraAr(string | undefined): Sets the camera aspect ratio whenvideoSourceis set to"camera"cameraFps(number | undefined): Sets the camera capture frame rate whenvideoSourceis set to"camera"cameraHighSpeed(boolean): Controls whether the camera should operate in high-speed mode whenvideoSourceis set to"camera"listCameras(boolean): Lists available cameras on the device and exitslistCameraSizes(boolean): Lists available camera sizes for a specific camera and exits
v2.6
audioDup(boolean): Controls whether to duplicate audio when capturing from the device
v3.0
captureOrientation(CaptureOrientation | string | undefined): Controls the orientation for video captureangle(number): Sets the rotation angle of the video stream in degreesscreenOffTimeout(number | undefined): Controls how long the device screen should remain on after the scrcpy connection is establishedlistApps(boolean): Lists installed applications on the device and exitsnewDisplay(NewDisplay | string | undefined): Creates a new virtual display for video streamingvdSystemDecorations(boolean): Controls whether the virtual display should include system decorations
v3.1
vdDestroyContent(boolean): Controls whether the virtual display content is destroyed when the connection is closed
v3.2
displayImePolicy("local" | "fallback" | "hide" | undefined): Controls the policy for displaying the Input Method Editor (IME) during screen mirroring
List of server options (by category)
Core Functionality
control(boolean): Disables the control socketscid(InstanceId | string | undefined): Specifies a session identifier for the Scrcpy server instance
Physical Display
displayId(number): Specifies which display to mirrormaxSize(number): Sets the maximum width and height of the video streammaxFps(number): Sets the maximum frame rate for the video stream in frames per secondsendFrameMeta(boolean)(since v1.15): Send presentation timestamps so that the client may record properlysendDeviceMeta(boolean)(since v1.22): Controls whether the server should send device name and size at the start of the video streamsendCodecMeta(boolean)(since v2.0): Controls whether codec metadata should be sent at the start of the video and audio streams
Display Orientation & Rotation
lockVideoOrientation: Locks the orientation of the video stream-
"-1 | 0 | 1 | 2 | 3"(until 1.17) -
"-2 | -1 | 0 | 1 | 2 | 3"(between 1.18 and 3.0) -
Deprecated, use
captureOrientationinstead(since v3.0)
-
captureOrientation(CaptureOrientation | string | undefined)(since v3.0): Controls the orientation for video captureangle(number)(since v3.0): Sets the rotation angle of the video stream in degrees
Camera
videoSource("display" | "camera")(since v2.2): Selects the video source for capturing video from the devicecameraId(string | undefined)(since v2.2): Specifies the camera ID to use whenvideoSourceis set to"camera"cameraSize(string | undefined)(since v2.2): Sets the camera capture size whenvideoSourceis set to"camera"cameraFacing("front" | "back" | "external" | undefined)(since v2.2): Specifies which camera facing direction to use whenvideoSourceis set to"camera"cameraAr(string | undefined)(since v2.2): Sets the camera aspect ratio whenvideoSourceis set to"camera"cameraFps(number | undefined)(since v2.2): Sets the camera capture frame rate whenvideoSourceis set to"camera"cameraHighSpeed(boolean)(since v2.2): Controls whether the camera should operate in high-speed mode whenvideoSourceis set to"camera"listCameras(boolean)(since v2.2): Lists available cameras on the device and exitslistCameraSizes(boolean)(since v2.2): Lists available camera sizes for a specific camera and exits
Virtual Display
newDisplay(NewDisplay | string | undefined)(since v3.0): Creates a new virtual display for video streamingvdSystemDecorations(boolean)(since v3.0): Controls whether the virtual display should include system decorationsvdDestroyContent(boolean)(since v3.1): Controls whether the virtual display content is destroyed when the connection is closeddisplayImePolicy("local" | "fallback" | "hide" | undefined)(since v3.2): Controls the policy for displaying the Input Method Editor (IME) during screen mirroring
Video Processing
videoCodec("h264" | "h265" | "av1")(since v2.0): Use H.265 or AV1 video codecsvideoBitRate(number)(since v2.0): Sets the video bitrate for the stream in bits per secondvideoCodecOptions(CodecOptions | string | undefined)(since v2.0): Configures video encoding parameters for the selected video codecvideoEncoder(string | undefined)(since v2.0): Specifies the name of the encoder to use for video encodingvideo(boolean)(since v2.1): Disables the video socket
Audio
audio(boolean)(since v2.0): Disables the audio socketaudioCodec: Specifies the audio codec to use by the server-
"raw" | "opus" | "aac"(between v2.0 and v2.2) -
"raw" | "opus" | "aac" | "flac"(since v2.3)
-
audioBitRate(number)(since v2.0): Sets the audio bitrate for the stream in bits per secondaudioCodecOptions(CodecOptions | string | undefined)(since v2.0): Configures audio encoding parameters for the selected audio codecaudioEncoder(string | undefined)(since v2.0): Specifies the name of the encoder to use for audio encodingaudioSource: Selects the audio source for capturing audio from the device-
"output" | "mic"(between v2.1 and v2.5) -
"output" | "mic" | "playback"(between v2.6 and v3.1) -
"output" | "mic" | "playback" | "mic-unprocessed" | "mic-camcorder" | "mic-voice-recognition" | "mic-voice-communication" | "voice-call" | "voice-call-uplink" | "voice-call-downlink" | "voice-performance"(since v3.2)
-
audioDup(boolean)(since v2.6): Controls whether to duplicate audio when capturing from the device
Device Controls
showTouches(boolean): Shows visual feedback for touches on the device screenstayAwake(boolean): Prevents the device from sleeping while screen casting is activepowerOffOnClose(boolean)(since v1.18): Automatically powers off the Android device when the scrcpy connection is closedpowerOn(boolean)(since v1.24): Controls whether the server should power on the device when starting streamingscreenOffTimeout(number | undefined)(since v3.0): Controls how long the device screen should remain on after the scrcpy connection is established
Data Management
crop(string | ScrcpyCrop): Crops the video stream to a specific regionclipboardAutosync(boolean)(since v1.21): Enables or disables automatic synchronization of clipboard content between device and client
Network & Connection
tunnelForward(boolean): Use ADB forward tunnel instead of reverse tunnelsendDummyByte(boolean)(since v1.22): Controls whether the server should send a0byte at the start of the video stream to detect connection issues
Encoding & Quality
bitRate: Sets the video bitrate for the stream in bits per second-
number(between v1.15 and v1.17) -
Deprecated, use
videoBitRateinstead(since v2.0)
-
codecOptions: Configures video encoding parameters for the selected codec-
string | ScrcpyCodecOptions(between v1.15 and v1.17) -
Deprecated, use
videoCodecOptionsinstead(since v2.0)
-
encoderName: Specifies the name of the encoder to use for video encoding-
string(between v1.17 and v1.17) -
Deprecated, use
videoEncoderinstead(since v2.0)
-
Error Handling & Performance
downsizeOnError(boolean)(since v1.22): Controls whether the server should downsize the video resolution when encountering initial encoding errors during startup
System & Cleanup
cleanup(boolean)(since v1.23): Controls whether the server should perform cleanup tasks on exit
Discovery & Debugging
listEncoders(boolean)(since v2.0): Lists available encoders on the device and exitslistDisplays(boolean)(since v2.0): Lists available displays on the device and exitslistApps(boolean)(since v3.0): Lists installed applications on the device and exits
Foundational Concepts
ScrcpyOptionValue: Interface for values that can be converted to scrcpy option stringslogLevel: Sets the logging level for the Scrcpy server-
"debug" | "info" | "warn" | "error"(until 1.17) -
"verbose" | "debug" | "info" | "warn" | "error"(since 1.18)
-