Skip to main content

寻找提示

warning

此功能处于试验阶段,尚未准备好投入生产使用。

当媒体解析器想要在媒体文件中定位到特定位置时,找出应去的位置可能非常耗费资源。

🌐 When Media Parser wants to seek to a specific position in the media file, it can be expensive to find out where to go.

使用寻求提示,你可以提前向媒体解析过程提供有关文件结构的提示,这样就可以在不需要确定位置的情况下直接执行寻求操作。

🌐 With Seeking Hints, you can provide a hint to the media parsing process upfront about the structure to the file, so that seeking can be short-circuited without needing to figure out the position.

寻求提示是由之前的 parseMedia() 调用产生的。

🌐 Seeking hints are produced from previous parseMedia() calls.

要获取搜索提示,你可以在控制器上调用 getSeekingHints()

🌐 To get seeking hints, you can call getSeekingHints() on the controller.

Getting seeking hints
import {mediaParserController, parseMedia} from '@remotion/media-parser'; const controller = mediaParserController(); await parseMedia({ controller, // Adding a callback so the full file is read onVideoTrack: (track) => { return (sample) => { console.log(sample); }; }, src: 'https://stream.mux.com/QkFQYWZ0ZS53ZWJ3aWQvc3RhdGlvbl9pbnRlcm5hbC5tM3U4Lm1wNA.m3u8', }); const hints = await controller.getSeekingHints();

使用寻求提示

🌐 Using seeking hints

一旦你从先前的解析中获得了寻求提示,你就可以将它们传递给新的 parseMedia()parseMediaOnWebWorker()parseMediaOnServerWorker()downloadAndParseMedia()convertMedia() 调用。

🌐 Once you have obtained seeking hints from a previous parse, you can pass them to a new parseMedia(), parseMediaOnWebWorker(), parseMediaOnServerWorker(), downloadAndParseMedia() or convertMedia() call.

Using seeking hints from a previous parse
await parseMedia({ controller, src: 'https://stream.mux.com/QkFQYWZ0ZS53ZWJ3aWQvc3RhdGlvbl9pbnRlcm5hbC5tM3U4Lm1wNA.m3u8', // Seeking hints were obtained from the previous parse seekingHints, });

很好知道

🌐 Good to know