Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ForeverSc committed Jun 2, 2024
1 parent 2aaf1aa commit 5059e5f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ npm install web-demuxer
import { WebDemuxer } from "web-demuxer"

const demuxer = new WebDemuxer({
wasmLoaderPath: "", // wasm file path
// ⚠️ you need to put the dist/wasm-files file in the npm package into a static directory like public, making sure that the js and wasm in wasm-files are in the same directory
wasmLoaderPath: "https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/wasm-files/ffmpeg.js",
})

// Take the example of seeking a video frame at a specified point in time
Expand Down Expand Up @@ -50,10 +51,19 @@ async function seek(time) {
```

## Examples
- [Seek Video Frame](https://foreversc.github.io/web-demuxer/#example-seek): [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L96)
- [Play Video](https://foreversc.github.io/web-demuxer/#example-play): [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L123)
- [Seek Video Frame](https://foreversc.github.io/web-demuxer/#example-seek) [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L96)
- [Play Video](https://foreversc.github.io/web-demuxer/#example-play) [code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L123)

## API
TODO: To be added, you can first look at the specific implementation in `src/web-demuxer.ts` with the `index.html` use case

### `getVideoDecoderConfig`
### `seekEncodedVideoChunk`
### `readAVPacket`
### `getAVStream`
### `getAVPacket`

## Custom Demuxer
TODO

## License
Expand Down
24 changes: 19 additions & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h4 align="right"><a href="https://github.com/ForeverSc/web-demuxer/blob/main/README.md">English</a> | <strong>简体中文</strong></h4>
<h1 align="center">Web-Demuxer</h1>
<p align="center">使用WebAssembly在浏览器中对媒体文件进行解码, 专门为WebCodecs设计</p>
<p align="center">使用WebAssembly在浏览器中对媒体文件进行解封装, 专门为WebCodecs设计</p>

## Purpose
WebCodecs只提供了decode的能力,但没有提供demux的能力。有一些JS解封装mp4box.js很酷,但它只支持mp4,Web-Demuxer的目的是一次性支持更多媒体格式
Expand All @@ -10,17 +10,18 @@ WebCodecs只提供了decode的能力,但没有提供demux的能力。有一些
- 📦 一次性支持多种媒体格式,比如mov/mp4/mkv/webm/flv/m4v/wmv/avi等等
- 🧩 支持自定义打包,可以调整配置,打包出指定格式的demuxer

### Install
## Install
```bash
npm install web-demuxer
```

### Usage
## Usage
```typescript
import { WebDemuxer } from "web-demuxer"

const demuxer = new WebDemuxer({
wasmLoaderPath: "", // wasm file path
// ⚠️ 你需要将npm包中dist/wasm-files文件放到类似public的静态目录下,保证wasm-files中的js和wasm在同一目录下
wasmLoaderPath: "https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/wasm-files/ffmpeg.js",
})

// 以获取指定时间点的视频帧为例
Expand Down Expand Up @@ -49,7 +50,20 @@ async function seek(time) {
}
```

### API
## 案例
- [Seek Video Frame](https://foreversc.github.io/web-demuxer/#example-seek)[code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L96)
- [Play Video](https://foreversc.github.io/web-demuxer/#example-play)[code](https://github.com/ForeverSc/web-demuxer/blob/main/index.html#L123)

## API
TODO: 待补充,你可以先看`src/web-demuxer.ts`中的具体实现与`index.html`的使用案例

### `getVideoDecoderConfig`
### `seekEncodedVideoChunk`
### `readAVPacket`
### `getAVStream`
### `getAVPacket`

## Custom Demuxer
TODO

## License
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h3>Play Video</h3>
const { WebDemuxer } = isDEV ? await import('./src') : await import('https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/web-demuxer.js')

const demuxer = new WebDemuxer({
wasmLoaderPath: isDEV ? "http://localhost:5173/src/lib/ffmpeg.js" : "https://cdn.jsdelivr.net/npm/web-demuxer@1.0.0/dist/wasm-files/ffmpeg.js",
wasmLoaderPath: isDEV ? "http://localhost:5173/src/lib/ffmpeg.js" : "https://cdn.jsdelivr.net/npm/web-demuxer@latest/dist/wasm-files/ffmpeg.js",
})

document.getElementById('example-seek-btn').addEventListener('click', async (e) => {
Expand Down

0 comments on commit 5059e5f

Please sign in to comment.