downloadAndParseMedia()
Same as parseMedia(), but also downloads the media file to disk.
Meant to be used in Node.js and Bun.
Download a filetsx
You can obtain fields like tracks and duration by passing them to the fields object.
Download a file and get metadatatsx
You can use callback functions to listen when new fields are available.
Throw an error to stop the download.
Stop the download if the video is too longtsx
If an error occurs (including one you've thrown yourself), you can decide what to do using onError.
Continue download despite errortsx
API
All of the same parameters for parseMedia() are available, plus:
writer
The writer to use to write the downloaded file to disk. Currently available:
- nodeWriterfrom- @remotion/media-parser/node-writer: Writes to disk using Node.js's- fsmodule.
onError
A function that is called when an error occurs. It receives the error as an argument.
You must return one of the following:
- {action: 'download'}: Continue downloading the file despite the error.
- {action: 'fail'}: Abort the download, delete the file and throw the error immediately.
See also the example above.
The function may be async, parsing is paused until it resolves.