Skip to main content
Version: next

Upgrade from 2.0.0

This page lists changes from version 2.0.0 in Scrcpy-related packages.

For changes in other packages, see this page.

New in beta 1

ScrcpyCodecOptions API improvements

ScrcpyCodecOptions and ScrcpyVideoCodecOptions classes have been updated with a more flexible API:

  • All setter methods now accept undefined to remove a previously set option. Previously, users had to call delete(key) and know the internal key name.
  • setLong now accepts number | bigint (previously only bigint). number values are converted via Math.floor.
  • setInt now validates that the value is within the int32 range (-2147483648 to 2147483647) and truncates it.

Before:

import { ScrcpyVideoCodecOptions } from "@yume-chan/scrcpy";

const options = new ScrcpyVideoCodecOptions()
.setProfile(1)
.setLong("key", 123n);

options.delete("key"); // Removing required knowing the internal key name

After:

import { ScrcpyVideoCodecOptions } from "@yume-chan/scrcpy";

const options = new ScrcpyVideoCodecOptions()
.setProfile(1)
.setProfile(undefined)
.setLong("key", 123);

@yume-chan/scrcpy

Support for Server Versions 4.0 and 4.1

Added support for Scrcpy server versions 4.0 and 4.1 with new option classes:

  • ScrcpyOptions4_0 - Supports Scrcpy server v4.0
  • ScrcpyOptions4_1 - Supports Scrcpy server v4.1

New Options in v4.0

  • minSizeAlignment: Sets the alignment for the minimum video stream size (1, 2, 4, 8, or 16 pixels)
  • cameraZoom: Sets the zoom level for the camera when using camera video source
  • cameraTorch: Controls whether the camera flashlight is enabled
  • flexDisplay: Enables flexible display mode for video streaming
  • keepActive: Keeps the device active while the Scrcpy connection is established
  • sendStreamMeta: Controls whether stream metadata is sent (replaces sendCodecMeta)

New Options in v4.1

  • videoCodec extended with "vp8" and "vp9" values
  • ignoreVideoEncoderConstraints: Ignores video encoder constraints when selecting an encoder

New Control Messages

  • cameraSetTorch(enabled: boolean): Control camera flashlight
  • cameraZoomIn(): Zoom in camera by one step
  • cameraZoomOut(): Zoom out camera by one step
  • resizeDisplay({ width, height }): Resize the device display
  • scanFile(path: string): Trigger media scan for a file (v4.1 only)

Breaking Changes

sendCodecMeta Removed, Replaced by sendStreamMeta

The sendCodecMeta option has been removed in v4.0. Use sendStreamMeta instead:

Before:

const options = new ScrcpyOptions3_3_4({
sendCodecMeta: false,
});

After:

const options = new ScrcpyOptions4_0({
sendStreamMeta: false,
});

Support for Multiple Minor Versions (v3.3.2, v3.3.3, v3.3.4)

Added support for newer Scrcpy server versions with dedicated option classes:

  • AdbScrcpyOptions3_3_2 - Supports Scrcpy server v3.3.2
  • AdbScrcpyOptions3_3_3 - Supports Scrcpy server v3.3.3
  • AdbScrcpyOptions3_3_4 - Supports Scrcpy server v3.3.4

These versions extend the corresponding core ScrcpyOptions classes and implement the AdbScrcpyOptions interface, providing ADB-specific functionality like connection creation, display listing, and encoder listing.

Updated CLASSPATH Parameter Usage

The ADB shell command format for launching Scrcpy server has been changed to use CLASSPATH= environment variable instead of the -cp flag. This change provides broader Android version compatibility, as the -cp argument requires Android 8.0:

Old approach:

const args = [
"app_process",
"-cp", // Old parameter format
path,
/* ... */
];

New approach:

const args = [
// Use `CLASSPATH=` as `-cp` argument requires Android 8.0
`CLASSPATH=${path}`, // New environment variable format
"app_process",
/* ... */
];

Renamed Method: setScreenPowerModesetDisplayPower

The setScreenPowerMode method on ScrcpyControlMessageWriter has been renamed to setDisplayPower for better clarity and consistency:

Old approach:

writer.setScreenPowerMode(mode);

New approach:

writer.setDisplayPower(mode);

@yume-chan/scrcpy-decoder-tinyh264@yume-chan/scrcpy-decoder-h264bsd

💥🔄 Replace TinyH264Decoder with H264BsdDecoder

The @yume-chan/scrcpy-decoder-tinyh264 package has been replaced by @yume-chan/scrcpy-decoder-h264bsd, a WebAssembly build of the Android H264BSD software decoder.

Migration guide:

  • Replace @yume-chan/scrcpy-decoder-tinyh264 with @yume-chan/scrcpy-decoder-h264bsd
  • Replace TinyH264Decoder with H264BsdDecoder
  • Replace decoder.renderer with decoder.canvas

Before:

import { TinyH264Decoder } from "@yume-chan/scrcpy-decoder-tinyh264";

const decoder = new TinyH264Decoder();
document.body.appendChild(decoder.renderer as HTMLCanvasElement);

videoPacketStream
.pipeTo(decoder.writable)
.catch(() => {});

After:

import { H264BsdDecoder } from "@yume-chan/scrcpy-decoder-h264bsd";

const decoder = new H264BsdDecoder();
document.body.appendChild(decoder.canvas as HTMLCanvasElement);

videoPacketStream
.pipeTo(decoder.writable)
.catch(() => {});

✨ Add worker option for Web Worker control

The H264BSD decoder adds a worker option to control whether decoding runs in a Web Worker. It accepts "auto" (default), true, or false.

✨ Add pause/resume and document visibility tracking

The decoder can now be paused/resumed with pause() and resume(). Use trackDocumentVisibility(document) to automatically pause when the page is hidden.

✨ Add video size properties and expanded metrics

The decoder now exposes width and height properties, and provides detailed rendering metrics including framesDecoded, framesSkippedDecoding, framesDisplayed, and decoderResetCount.