寻找提示
此功能处于试验阶段,尚未准备好投入生产使用。
当媒体解析器想要在媒体文件中定位到特定位置时,找出应去的位置可能非常耗费资源。
🌐 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 hintsimport {mediaParserController ,parseMedia } from '@remotion/media-parser'; constcontroller =mediaParserController (); awaitparseMedia ({controller , // Adding a callback so the full file is readonVideoTrack : (track ) => { return (sample ) => {console .log (sample ); }; },src : 'https://stream.mux.com/QkFQYWZ0ZS53ZWJ3aWQvc3RhdGlvbl9pbnRlcm5hbC5tM3U4Lm1wNA.m3u8', }); consthints = awaitcontroller .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 parseawaitparseMedia ({controller ,src : 'https://stream.mux.com/QkFQYWZ0ZS53ZWJ3aWQvc3RhdGlvbl9pbnRlcm5hbC5tM3U4Lm1wNA.m3u8', // Seeking hints were obtained from the previous parseseekingHints , });
很好知道
🌐 Good to know
- 在解析过程中随时都可以获取提示,而不仅仅是在结束时。
- 寻求提示的数据结构不是公共 API 的一部分,并且可能随时更改。
- 解析后,只有在解析成功或中止时才能获取提示,而在解析失败时则无法获取提示。
- 可以为
parseMediaOnWebWorker()和parseMediaOnServerWorker()获取提示。 - 一个
mediaParserController()只能附加到 1 个parseMedia()调用上。 - 寻求提示可以传递给
convertMedia()。