Skip to main content

parseMediaOnWebWorker()

warning

Unstable API: This package is experimental. The API may change in the future.
The API for getting video metadata is stable and may be used in production.

This API works the same as parseMedia(), except that it executes the parse on a Web Worker. Web Workers are only available in Browsers and in Bun.

This is useful if you are processing large files which parsing process would block the UI thread for a longer time.

This API abstracts the communication between the main thread and the worker with the goal to keep the same API as parseMedia(), including capabilities like supporting mediaParserController() all async callback functions.

The only difference in API is that the reader option is not available. This is because you cannot pass a function to a Web Worker.

Parsing a video on a Web Worker
tsx
import {parseMediaOnWebWorker} from '@remotion/media-parser';
 
const result = await parseMediaOnWebWorker({
src: 'https://example.com/my-video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,
},
});
 
console.log(result.durationInSeconds); // 10
console.log(result.dimensions); // {width: 1920, height: 1080}

API

Same as parseMedia(), but without the option to pass a reader.

The reader option in the worker is hardcoded to webReader.

See also