You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -59,7 +62,7 @@ async function seek(file, time) {
59
62
});
60
63
61
64
decoder.configure(videoDecoderConfig);
62
-
decoder.decode(videoChunk);
65
+
decoder.decode(videoEncodedChunk);
63
66
decoder.flush();
64
67
}
65
68
```
@@ -70,14 +73,13 @@ async function seek(file, time) {
70
73
71
74
## API
72
75
```typescript
73
-
newWebDemuxer(options: WebDemuxerOptions)
76
+
newWebDemuxer(options?:WebDemuxerOptions)
74
77
```
75
78
Creates a new instance of `WebDemuxer`.
76
79
77
80
Parameters:
78
-
-`options`: Required, configuration options.
79
-
-`wasmLoaderPath`: Required, the path to the corresponding JavaScript loader file for wasm (corresponding to the `ffmpeg.js` or `ffmpeg-mini.js` in the `dist/wasm-files` directory of the npm package).
80
-
> ⚠️ You must ensure that the wasm and JavaScript loader files are placed in the same accessible directory, the JavaScript loader will default to requesting the wasm file in the same directory.
81
+
-`options`: Optional, configuration options.
82
+
-`wasmFilePath`: Optional, customize the WASM file path, it defaults to looking for WASM files in the same directory as the script file.
81
83
82
84
```typescript
83
85
load(source: File|string): Promise<void>
@@ -88,90 +90,33 @@ Parameters:
88
90
-`source`: Required, support the `File` object or file URL to be processed.
Parses the video stream to obtain the `VideoDecoderConfig` of the file, and the return value can be directly used as an argument for the `configure` method of `VideoDecoder`.
Parses the audio stream to obtain the `AudioDecoderConfig` of the file, and the return value can be directly used as an argument for the `configure` method of `AudioDecoder`.
Retrieves the video data at the specified time point (default keyframe), and the return value can be directly used as an argument for the `decode` method of `VideoDecoder`.
104
-
105
-
Parameters:
106
-
-`time`: Required, in seconds.
107
-
-`seekFlag`: The seek flag, defaults to 1 (seek backward). See `AVSeekFlag` for more details.
Retrieves the audio data at the specified time point, and the return value can be directly used as an argument for the `decode` method of `AudioDecoder`.
113
-
114
-
Parameters:
115
-
-`time`: Required, in seconds.
116
-
-`seekFlag`: The seek flag, defaults to 1 (seek backward). See `AVSeekFlag` for more details.
Returns a `ReadableStream` for streaming packet data.
95
+
Get decoder configuration for WebCodecs based on media type ('video' or 'audio'). Returns `VideoDecoderConfig` or `AudioDecoderConfig` that can be used directly with WebCodecs.
122
96
123
97
Parameters:
124
-
-`start`: The start time for reading, in seconds, defaults to 0, reading packets from the beginning.
125
-
-`end`: The end time for reading, in seconds, defaults to 0, reading until the end of the file.
126
-
-`streamType`: The type of media stream, defaults to 0, which is the video stream. 1 is audio stream. See `AVMediaType` for more details.
127
-
-`streamIndex`: The index of the media stream, defaults to -1, which is to automatically select.
128
-
-`seekFlag`: The seek flag, defaults to 1 (seek backward). See `AVSeekFlag` for more details.
129
-
130
-
Simplified methods based on the semantics of `readAVPacket`:
Currently, two versions of the demuxer are provided by default to support different formats:
275
-
-`dist/wasm-files/ffmpeg.js`: Full version (gzip: 996 kB), larger in size, supports mov, mp4, m4a, 3gp, 3g2, mj2, avi, flv, matroska, webm, m4v, mpeg, asf, mpegts
276
-
-`dist/wasm-files/ffmpeg-mini.js`: Minimalist version (gzip: 456 kB), smaller in size, only supports mov, mp4, m4a, 3gp, 3g2, matroska, webm, m4v
277
-
> If you want to use a smaller size version, you can use version 1.0 of web-demuxer, the lite version is only 115KB
278
-
> Version 1.0 is written in C, focuses on WebCodecs, and is small in size, while version 2.0 uses C++ Embind, which provides richer media information output, is easier to maintain, and is large in size
219
+
Retrieves the media data at the specified time point.
279
220
280
-
You can also implement a demuxer for specific formats through custom configuration:
221
+
Parameters:
222
+
- `type`: Required, the type of media ('video' or 'audio')
223
+
- `time`: Required, in seconds
224
+
- `seekFlag`: Optional, seek flag, defaults to 1 (backward seek). See `AVSeekFlag` for details.
281
225
282
-
First, modify the `enable-demuxer` configuration in the `Makefile`
0 commit comments