parseMediaOnServerWorker()
此 API 与 parseMediaOnWebWorker() 相同,但除了可以从 URL 和 File 对象读取外,你还可以传入文件路径,这些文件路径将使用 fs 模块读取。
🌐 This API is the same as parseMediaOnWebWorker(), but besides reading from URLs and File objects, you can also pass file paths that will be read using the fs module.
这使得该函数也能在服务器上工作,但与浏览器不兼容。
🌐 This makes the function also work on the server, but incompatible with the browser.
只有 Bun 支持 Worker,而 Node.js 不支持。这意味着目前这个功能仅在你想在 Bun 的工作线程上运行媒体解析时才有意义。
🌐 Only Bun has support for Worker, while Node.js does not. That means that this function currently only makes sense if you want to run a media parse on Bun on a worker thread.
我们不测试 Deno 的 Worker 实现。
Parsing a video on a Bun Workerimport {parseMediaOnServerWorker } from '@remotion/media-parser/server-worker'; constresult = awaitparseMediaOnServerWorker ({src : '/tmp/video.mp4',fields : {durationInSeconds : true,dimensions : true, }, });console .log (result .durationInSeconds ); // 10console .log (result .dimensions ); // {width: 1920, height: 1080}
应用编程接口
🌐 API
与 parseMedia() 相同,但没有传递 reader 的选项。
🌐 Same as parseMedia(), but without the option to pass a reader.
worker 中的 reader 选项被硬编码为 universalReader。
🌐 The reader option in the worker is hardcoded to universalReader.
另请参阅
🌐 See also