Skip to content

Commit 58e79cd

Browse files
committed
Add fetchFile to api doc
1 parent d99801c commit 58e79cd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [ffmpeg.setLogging](#ffmpeg-setlogging)
88
- [ffmpeg.setLogger](#ffmpeg-setlogger)
99
- [ffmpeg.setProgress](#ffmpeg-setProgress)
10+
- [fetchFile](#fetch-file)
1011

1112
---
1213

@@ -159,3 +160,28 @@ ffmpeg.setProgress(({ ratio }) => {
159160
*/
160161
});
161162
```
163+
164+
<a name="fetch-file"></a>
165+
166+
### fetchFile(media): Promise
167+
168+
Helper function for fetching files from various resource.
169+
170+
Sometimes the video/audio file you want to process may located in a remote URL and somewhere in your local file system.
171+
172+
This helper function helps you to fetch to file and return an Uint8Array variable for ffmpeg.wasm to consume.
173+
174+
**Arguments**
175+
176+
- `media` an URL string, base64 string or File, Blob, Buffer object
177+
178+
**Examples:**
179+
180+
```javascript
181+
(async () => {
182+
const data = await fetchFile('https://github.com/ffmpegwasm/testdata/raw/master/video-3s.avi');
183+
/*
184+
* data will be in Uint8Array format
185+
*/
186+
})();
187+
```

0 commit comments

Comments
 (0)