Skip to content

Commit

Permalink
📝 Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
yumexupanic committed Apr 27, 2024
1 parent 1f257a0 commit 3e98825
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,26 @@ import WSFMP4 from "wsfmp4.js";
let media = document.querySelector("#video");

let wsfmp4 = new WSFMP4(media, {
debug: true,
url: "ws://127.0.0.1:6060/stream",
debug: true,
live: true,
retry: true,
liveMaxLatency: 8,
cacheMax: 4,
});
```

### Parameter

- debug: Enable debug mode, which will output detailed logs. Default is false.
- live: Enable live mode. Default is false.
- liveMaxLatency: Maximum allowed latency for live streaming. Default is 0.
- debug Enable debug mode, will output detailed log default false
- retry Enable retry mode by default false (recommended for live broadcast)
- live Enable live mode default false (recommended to enable live)
- liveMaxLatency The maximum latency of the live broadcast, after exceeding it, it will refresh to the latest frame automatically Unit second Default 0 (recommended configuration for live broadcast)
- cacheMax Maximum length of cache, buffer will be cleaned up automatically in seconds Default 8

For live streaming, it is recommended to turn on the configuration related to live streaming, which can effectively control the latency. Live streaming latency usually requires the cooperation of the server and the client, and the client mainly handles the content refresh of the cache and the management of the buffer. The client mainly handles the cache content refresh and buffer management. After the live state is turned on, some optimizations will be performed by default. In addition, the configuration of liveMaxLatency is more important, set too small video will frequently wait, too large delay is high. Specific parameters need to be based on how often the server side encapsulates a packet of data related, there is no universal value.

In live mode, it is recommended to enable the retry function, the default disconnect 3s after the automatic reconnection

### Fucntions

Expand Down
24 changes: 16 additions & 8 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

[English](https://github.com/yumexupanic/wsfmp4.js) | [简体中文](https://github.com/yumexupanic/wsfmp4.js/blob/main/README_zh.md)


wsfmp4.js 支持在浏览器中使用 websocket 传输的 fmp4 数据进行播放,使用 MSE 技术实现。
wsfmp4.js 支持在浏览器中使用 websocket 传输的 fmp4 数据进行播放,使用 MSE 技术实现,支持 h264 以及 h265。

![wsfmp4](https://imgur.cloud/wsfmp4/wsfmp4.jpg)


DEMO: <https://wsfmp4-js.pages.dev>

## 快速开始

流媒体服务(如果你有流媒体,可以跳过此步)

```shell
# ws://127.0.0.1:6060/stream
docker run -d -p 6060:6060 wsfmp4
Expand All @@ -27,18 +27,26 @@ import WSFMP4 from "wsfmp4.js";
let media = document.querySelector("#video");

let wsfmp4 = new WSFMP4(media, {
debug: true,
live: false,
liveMaxLatency: 4
url: "ws://127.0.0.1:6060/stream",
debug: true,
live: true,
retry: true,
liveMaxLatency: 8,
cacheMax: 4,
});
```

### 参数说明

- debug 开启调试模式,会输出详细 log 默认 false
- live 开启直播模式 默认 false
- liveMaxLatency 允许的直播最大延迟,默认 0
- retry 开启重试 默认 false (直播推荐开启)
- live 开启直播模式 默认 false (直播推荐开启)
- liveMaxLatency 直播最大延迟,超过后会自动刷新到最新帧 单位秒 默认 0 (直播推荐配置)
- cacheMax 缓存的最大时长,自动清理 buffer 单位秒 默认 8

对于直播流,推荐开启直播相关的配置,能有效的控制延时,直播延时通常需要服务器和客户端配合,客户端主要处理缓存的内容刷新以及 buffer 的管理。开启了直播状态后,默认会进行一些优化。另外 liveMaxLatency 的配置比较重要,设置的太小视频会频繁的等待,太大会延迟较高。具体的参数需要根据服务端多久封装一包数据有关,没有通用的值。

直播模式下,推荐开启重试功能,默认断开 3s 后自动重连

### 函数

Expand Down

0 comments on commit 3e98825

Please sign in to comment.