🎥 Make videos programmatically with React
working on seeking docs
Jonny Burger3228f6584f0e
diff --git a/packages/docs/docs/media-parser/seeking.mdx b/packages/docs/docs/media-parser/seeking.mdxindex 0422b391ca..c57ce8f45a 100644--- a/packages/docs/docs/media-parser/seeking.mdx+++ b/packages/docs/docs/media-parser/seeking.mdx@@ -10,6 +10,54 @@ crumb: '@remotion/media-parser'**In construction:** Seeking is not yet supported and you should not yet use it. This documentation page is a living document allowing us to write down the rules:::+In [`parseMedia()`](/docs/media-parser/parse-media), [`parseMediaOnWebWorker()`](/docs/parse-media/parse-media-on-worker) and [`parseMediaOnServerWorker()`](/docs/parse-media/parse-media-on-server-worker), you can seek to a different position in the media file.++```tsx twoslash title="Basic seeking"+import {parseMedia, mediaParserController} from '@remotion/media-parser';++const controller = mediaParserController();++// You can make a seek even before starting a parse+// This will be considered before emitting the first sample+controller._experimentalSeek({+ type: 'keyframe-before-time-in-seconds',+ time: 5,+});++await parseMedia({+ src: 'https://example.com/video.mp4',+ controller,+ onVideoTrack: () => {+ return () => {+ // You can also seek inmidst a parse.+ controller._experimentalSeek({+ type: 'keyframe-before-time-in-seconds',+ time: 10,+ });+ };+ },+});+```++## Types of seek++### `keyframe-before-time-in-seconds`++This will seek to the last keyframe that comes before a certain time. If there is a keyframe at exactly this time, it will seek to this one.++Remember that if you want to decode a video, you always have to start at a keyframe. If you are not interested in the frames before `time`, you still need to decode them, but you may discard them.++```tsx twoslash title="Seeking to a keyframe"+import {mediaParserController} from '@remotion/media-parser';++const controller = mediaParserController();++controller._experimentalSeek({+ type: 'keyframe-before-time-in-seconds',+ time: 5,+});+```+## When you cannot seekIt is not allowed to **seek forward** if any of the following [fields](/docs/media-parser/fields) are required:@@ -17,3 +65,7 @@ It is not allowed to **seek forward** if any of the following [fields](/docs/medimport {DisallowForwardSeekingFields} from './DisallowForwardSeekingFields';<DisallowForwardSeekingFields />++The reason for this is that all samples need to be iterated over for these fields to be calculated. By seeking forward, some samples would be skipped which would skew the results.++An error will be thrown if you attempt to do this.