Skip to main content

@ffmpeg/util

Functions​

downloadWithProgress​

▸ downloadWithProgress(url, cb?): Promise<ArrayBuffer>

Download content of a URL with progress.

Progress only works when Content-Length is provided by the server.

Parameters​

NameType
urlstring | URL
cb?ProgressCallback

Returns​

Promise<ArrayBuffer>

Defined in​

index.ts:104


fetchFile​

▸ fetchFile(file?): Promise<Uint8Array>

An util function to fetch data from url string, base64, URL, File or Blob format.

Examples:

// URL
await fetchFile("http://localhost:3000/video.mp4");
// base64
await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
// URL
await fetchFile(new URL("video.mp4", import.meta.url));
// File
fileInput.addEventListener('change', (e) => {
await fetchFile(e.target.files[0]);
});
// Blob
const blob = new Blob(...);
await fetchFile(blob);

Parameters​

NameType
file?string | Blob | File

Returns​

Promise<Uint8Array>

Defined in​

index.ts:49


importScript​

▸ importScript(url): Promise<void>

importScript dynamically import a script, useful when you want to use different versions of ffmpeg.wasm based on environment.

Example:

await importScript("http://localhost:3000/ffmpeg.js");

Parameters​

NameType
urlstring

Returns​

Promise<void>

Defined in​

index.ts:85


toBlobURL​

▸ toBlobURL(url, mimeType, progress?, cb?): Promise<string>

toBlobURL fetches data from an URL and return a blob URL.

Example:

await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");

Parameters​

NameTypeDefault value
urlstringundefined
mimeTypestringundefined
progressbooleanfalse
cb?ProgressCallbackundefined

Returns​

Promise<string>

Defined in​

index.ts:170