Seeking Hints
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.
Seeking hints are produced from previous parseMedia()
calls.
To get seeking hints, you can call getSeekingHints()
on the controller.
Getting seeking hintstsx
import {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
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 parsetsx
awaitparseMedia ({controller ,src : 'https://stream.mux.com/QkFQYWZ0ZS53ZWJ3aWQvc3RhdGlvbl9pbnRlcm5hbC5tM3U4Lm1wNA.m3u8',// Seeking hints were obtained from the previous parseseekingHints ,});
Good to know
- Seeking hints can be fetched at any time also during the parsing process, not only at the end.
- The data structure of the seeking hints is not part of the public API and may change at any time.
- After the parse, seeking hints are only available if the parse was successful or aborted, not when it failed.
- Seeking hints are available for
parseMediaOnWebWorker()
andparseMediaOnServerWorker()
. - A
mediaParserController()
can only be attached to 1parseMedia()
call. - Seeking hints can be passed to
convertMedia()
.