parseMediaOnWebWorker()
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 Workertsx
import {parseMediaOnWebWorker } from '@remotion/media-parser/worker';constresult = awaitparseMediaOnWebWorker ({src : 'https://parser.media/video.mp4',fields : {durationInSeconds : true,dimensions : true,},});console .log (result .durationInSeconds ); // 10console .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
.