Skip to content

🎥 Make videos programmatically with React

reject live streams

Jonny Burgerc56406cfccc2
diff --git a/packages/convert/app/lib/use-thumbnail.ts b/packages/convert/app/lib/use-thumbnail.ts
index 3ebc3aaf4f..6b952ec48f 100644
--- a/packages/convert/app/lib/use-thumbnail.ts
+++ b/packages/convert/app/lib/use-thumbnail.ts
@@ -32,6 +32,18 @@ export const useThumbnailAndWaveform = ({
const videoTrack = await input.getPrimaryVideoTrack();
if (videoTrack) {
+ if (await videoTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry!',
+ );
+ }
+
+ if (await videoTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry!',
+ );
+ }
+
const videoSink = new VideoSampleSink(videoTrack);
let samples = 0;
const iterator = videoSink.samples();
diff --git a/packages/media-utils/src/use-windowed-audio-data.ts b/packages/media-utils/src/use-windowed-audio-data.ts
index 26c9e6e9ef..032d9085c4 100644
--- a/packages/media-utils/src/use-windowed-audio-data.ts
+++ b/packages/media-utils/src/use-windowed-audio-data.ts
@@ -122,6 +122,20 @@ export const useWindowedAudioData = ({
throw new Error('No audio track found');
}
+ if (await audioTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
+ if (await audioTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
const canDecode = await audioTrack.canDecode();
if (!canDecode) {
diff --git a/packages/media/src/media-player.ts b/packages/media/src/media-player.ts
index c2abafcd83..527561ba5a 100644
--- a/packages/media/src/media-player.ts
+++ b/packages/media/src/media-player.ts
@@ -269,6 +269,20 @@ export class MediaPlayer {
}
if (videoTrack && this.tagType === 'video') {
+ if (await videoTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ this.src,
+ );
+ }
+
+ if (await videoTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ this.src,
+ );
+ }
+
const canDecode = await videoTrack.canDecode();
if (!canDecode) {
@@ -302,6 +316,20 @@ export class MediaPlayer {
}
if (audioTrack && this.sharedAudioContext) {
+ if (await audioTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ this.src,
+ );
+ }
+
+ if (await audioTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ this.src,
+ );
+ }
+
const canDecode = await audioTrack.canDecode();
if (!canDecode) {
return {type: 'cannot-decode'};
diff --git a/packages/media/src/video-extraction/get-frames-since-keyframe.ts b/packages/media/src/video-extraction/get-frames-since-keyframe.ts
index 83c1783992..9fa121c4df 100644
--- a/packages/media/src/video-extraction/get-frames-since-keyframe.ts
+++ b/packages/media/src/video-extraction/get-frames-since-keyframe.ts
@@ -83,6 +83,20 @@ export const getSinks = async (
return 'no-video-track';
}
+ if (await videoTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
+ if (await videoTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
const canDecode = await videoTrack.canDecode();
if (!canDecode) {
diff --git a/packages/studio/src/components/CurrentAsset.tsx b/packages/studio/src/components/CurrentAsset.tsx
index b0b4ebccbe..26aa0955d0 100644
--- a/packages/studio/src/components/CurrentAsset.tsx
+++ b/packages/studio/src/components/CurrentAsset.tsx
@@ -100,6 +100,20 @@ export const CurrentAsset: React.FC = () => {
input.getPrimaryVideoTrack(),
])
.then(async ([duration, format, videoTrack]) => {
+ if (videoTrack && (await videoTrack.isLive())) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ url,
+ );
+ }
+
+ if (videoTrack && (await videoTrack.isRelativeToUnixEpoch())) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ url,
+ );
+ }
+
setMediaMetadata({
duration,
format: format.name,
diff --git a/packages/studio/src/components/load-waveform-peaks.ts b/packages/studio/src/components/load-waveform-peaks.ts
index 4c7efee598..a12986ca2d 100644
--- a/packages/studio/src/components/load-waveform-peaks.ts
+++ b/packages/studio/src/components/load-waveform-peaks.ts
@@ -24,6 +24,20 @@ export async function loadWaveformPeaks(
return new Float32Array(0);
}
+ if (await audioTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ url,
+ );
+ }
+
+ if (await audioTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ url,
+ );
+ }
+
const sampleRate = await audioTrack.getSampleRate();
const durationInSeconds =
(await audioTrack.getDurationFromMetadata({skipLiveWait: true})) ??
diff --git a/packages/studio/src/helpers/extract-frames.ts b/packages/studio/src/helpers/extract-frames.ts
index bb3978da57..ad891b06fe 100644
--- a/packages/studio/src/helpers/extract-frames.ts
+++ b/packages/studio/src/helpers/extract-frames.ts
@@ -54,6 +54,20 @@ export async function extractFrames({
throw new Error('No video track found in the input');
}
+ if (await videoTrack.isLive()) {
+ throw new Error(
+ 'Live streams are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
+ if (await videoTrack.isRelativeToUnixEpoch()) {
+ throw new Error(
+ 'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +
+ src,
+ );
+ }
+
const timestamps =
typeof timestampsInSeconds === 'function'
? await timestampsInSeconds({