🎥 Make videos programmatically with React
Warn about non-seekable media
Jonny Burger955fbc0d4a6a
diff --git a/packages/core/src/use-media-playback.ts b/packages/core/src/use-media-playback.tsindex b6be68e27a..151bf8e369 100644--- a/packages/core/src/use-media-playback.ts+++ b/packages/core/src/use-media-playback.ts@@ -4,6 +4,7 @@ import {usePlayingState} from './timeline-position-state';import {useAbsoluteCurrentFrame, useCurrentFrame} from './use-frame';import {useVideoConfig} from './use-video-config';import {getMediaTime} from './video/get-current-time';+import {warnAboutNonSeekableMedia} from './warn-about-non-seekable-media';export const useMediaPlayback = ({mediaRef,@@ -59,6 +60,7 @@ export const useMediaPlayback = ({// If scrubbing around, adjust timing// or if time shift is bigger than 0.2secmediaRef.current.currentTime = shouldBeTime;+ warnAboutNonSeekableMedia(mediaRef.current);}if (!playing || absoluteFrame === 0) {diff --git a/packages/core/src/warn-about-non-seekable-media.ts b/packages/core/src/warn-about-non-seekable-media.tsnew file mode 100644index 0000000000..637429ca2d--- /dev/null+++ b/packages/core/src/warn-about-non-seekable-media.ts@@ -0,0 +1,27 @@+const alreadyWarned: {[key: string]: boolean} = {};++export const warnAboutNonSeekableMedia = (ref: HTMLMediaElement) => {+ // Media is not loaded yet, but this does not yet mean something is wrong with the media+ if (ref.seekable.length === 0) {+ return;+ }++ if (ref.seekable.length > 1) {+ return;+ }++ if (alreadyWarned[ref.src]) {+ return;+ }++ const range = {start: ref.seekable.start(0), end: ref.seekable.end(0)};++ if (range.start === 0 && range.end === 0) {+ console.error(+ 'The media',+ ref.src,+ 'does not seem to support seeking. Remotion cannot properly handle it. Please see https://remotion.dev/docs/non-seekable-media for assistance.'+ );+ alreadyWarned[ref.src] = true;+ }+};diff --git a/packages/docs/docs/non-seekable-media.md b/packages/docs/docs/non-seekable-media.mdnew file mode 100644index 0000000000..9ebf895f2c--- /dev/null+++ b/packages/docs/docs/non-seekable-media.md@@ -0,0 +1,24 @@+---+id: non-seekable-media+title: Non-seekable media+---++If you see the following error in the console:++```+The media [audio source] does not seem to support seeking. Remotion cannot properly handle it. Please see https://remotion.dev/docs/non-seekable-media for assistance.+```++it means you have provided a video or audio that cannot be seeked to an arbitrary time. The cause for this is that when requesting the audio file, no `Content-Range` HTTP header has been sent by the server, making it impossible for the browser and therefore for Remotion to seek the media.++## Reproduction++You can verify that this is the problem by opening the video or audio in a new tab and observe that you cannot seek the media.++So far, this behavior has been observed when serving media from a private Google Cloud Storage bucket.++## Solution++To fix this problem, you need to serve the media from a webhost that supports the `Range` header.++Alternatively, you can download the media and import it locally using an `import` or `require()` statement.diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 3ec682af06..1cf91c4230 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -98,6 +98,7 @@ module.exports = {"media-playback-error","performance","webpack-dynamic-imports",+ "non-seekable-media",],},"2-0-migration",