Skip to content

Commit

Permalink
add how to record the video stream
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Dec 25, 2024
1 parent 57e752c commit 5c49199
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"libusb",
"logcat",
"muxer",
"muxing",
"MVVM",
"nohostname",
"nouser",
Expand Down
3 changes: 3 additions & 0 deletions docs/scrcpy/control/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Control device

import Version from "../version-span";

Scrcpy supports various input events, including mouse, touch, keyboard, and physical buttons. The client sends input events to the server, which injects them into the device.

There are three ways to create or send control messages, they provide the same set of methods:
Expand All @@ -15,6 +17,7 @@ There are three ways to create or send control messages, they provide the same s
- Collapse panels: Collapse the notification and quick settings panels.
- [Rotate device](./rotate.mdx): Change the device orientation.
- Set clipboard: Set the device clipboard (only supports plain text).
- <Version since="v3.0">[Reset video](./reset-video.mdx): Restart video capture and encoding.</Version>

## Using `@yume-chan/scrcpy`

Expand Down
34 changes: 34 additions & 0 deletions docs/scrcpy/control/reset-video.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 12
---

# Reset video

:::info

Added in Scrcpy 3.0

:::

Restart video capture and encoding.

Because a video must start with a configuration and keyframe to be decoded, sometimes you might want to manually restart video capture and encoding, which produces a new configuration packet and keyframe data packet immediately.

For example, when you want to [save a video](../video/record.mdx) from a specific point, or stream the video to multiple players, and a new player is added.

Reset video will cause a very small pause in the video stream, but it should be acceptable for most cases.

## Usage

```ts transpile
import { AndroidKeyEventAction } from "@yume-chan/scrcpy";

// Using `ScrcpyControlMessageSerializer`
const message: Uint8Array = serializer.resetVideo();

// Using `ScrcpyControlMessageWriter`
await writer.resetVideo();

// Using `AdbScrcpyClient`
await client.controller!.resetVideo();
```
4 changes: 2 additions & 2 deletions docs/scrcpy/video/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ When the encoder is restarted, a new configuration packet will be generated and

The `data` field contains the codec-specific configuration information:

* H.264: Sequence Parameter Set (SPS) and Picture Parameter Set (PPS)
* H.265: Video Parameter Set (VPS), Sequence Parameter Set (SPS), and Picture Parameter Set (PPS)
* H.264: Sequence Parameter Set (SPS) and Picture Parameter Set (PPS) in Annex B format.
* H.265: Video Parameter Set (VPS), Sequence Parameter Set (SPS), and Picture Parameter Set (PPS) in Annex B format.
* AV1: The first 3 bytes of `AV1CodecConfigurationRecord` (https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox). The remaining configuration OBUs are in the next data packet.

The client should handle this packet and update the decoder accordingly.
Expand Down
Loading

0 comments on commit 5c49199

Please sign in to comment.