Skip to content

🎥 Make videos programmatically with React

`@remotion/media`: Support loopVolumeCurveBehavior

Jonny Burgerb7ea8ba1c179
diff --git a/packages/media/src/audio-extraction/extract-audio.ts b/packages/media/src/audio-extraction/extract-audio.ts
index f3b88212a0..6fac94353b 100644
--- a/packages/media/src/audio-extraction/extract-audio.ts
+++ b/packages/media/src/audio-extraction/extract-audio.ts
@@ -14,7 +14,6 @@ export const extractAudio = async ({
src,
timeInSeconds: unloopedTimeInSeconds,
durationInSeconds,
- volume,
logLevel,
loop,
playbackRate,
@@ -22,11 +21,13 @@ export const extractAudio = async ({
src: string;
timeInSeconds: number;
durationInSeconds: number;
- volume: number;
logLevel: LogLevel;
loop: boolean;
playbackRate: number;
-}): Promise<PcmS16AudioData | null> => {
+}): Promise<{
+ data: PcmS16AudioData | null;
+ durationInSeconds: number | null;
+}> => {
if (!sinkPromises[src]) {
sinkPromises[src] = getSinks(src);
}
@@ -34,12 +35,17 @@ export const extractAudio = async ({
const {audio, actualMatroskaTimestamps, isMatroska, getDuration} =
await sinkPromises[src];
+ let duration: number | null = null;
+ if (loop) {
+ duration = await getDuration();
+ }
+
if (audio === null) {
- return null;
+ return {data: null, durationInSeconds: null};
}
const timeInSeconds = loop
- ? unloopedTimeInSeconds % (await getDuration())
+ ? unloopedTimeInSeconds % duration!
: unloopedTimeInSeconds;
const sampleIterator = await audioManager.getIterator({
@@ -108,7 +114,6 @@ export const extractAudio = async ({
trimStartInSeconds,
trimEndInSeconds,
targetNumberOfChannels: TARGET_NUMBER_OF_CHANNELS,
- volume,
playbackRate,
});
audioDataRaw.close();
@@ -121,10 +126,10 @@ export const extractAudio = async ({
}
if (audioDataArray.length === 0) {
- return null;
+ return {data: null, durationInSeconds: duration};
}
const combined = combineAudioDataAndClosePrevious(audioDataArray);
- return combined;
+ return {data: combined, durationInSeconds: duration};
};
diff --git a/packages/media/src/audio/audio-for-rendering.tsx b/packages/media/src/audio/audio-for-rendering.tsx
index fa766eb6c1..f1691303cc 100644
--- a/packages/media/src/audio/audio-for-rendering.tsx
+++ b/packages/media/src/audio/audio-for-rendering.tsx
@@ -1,5 +1,5 @@
import type React from 'react';
-import {useContext, useLayoutEffect, useMemo, useState} from 'react';
+import {useContext, useLayoutEffect, useState} from 'react';
import {
cancelRender,
Internals,
@@ -7,6 +7,7 @@ import {
useDelayRender,
useRemotionEnvironment,
} from 'remotion';
+import {frameForVolumeProp} from '../looped-frame';
import {extractFrameViaBroadcastChannel} from '../video-extraction/extract-frame-via-broadcast-channel';
import type {AudioProps} from './props';
@@ -21,15 +22,15 @@ export const AudioForRendering: React.FC<AudioProps> = ({
logLevel = window.remotion_logLevel,
loop,
}) => {
+ const frame = useCurrentFrame();
const absoluteFrame = Internals.useTimelinePosition();
+
const videoConfig = Internals.useUnsafeVideoConfig();
const {registerRenderAsset, unregisterRenderAsset} = useContext(
Internals.RenderAssetManager,
);
- const frame = useCurrentFrame();
- const volumePropsFrame = Internals.useFrameForVolumeProp(
- loopVolumeCurveBehavior ?? 'repeat',
- );
+ const startsAt = Internals.useMediaStartsAt();
+
const environment = useRemotionEnvironment();
const [id] = useState(() => `${Math.random()}`.replace('0.', ''));
@@ -42,30 +43,6 @@ export const AudioForRendering: React.FC<AudioProps> = ({
throw new TypeError('No `src` was passed to <Audio>.');
}
- const volume = Internals.evaluateVolume({
- volume: volumeProp,
- frame: volumePropsFrame,
- mediaVolume: 1,
- });
-
- Internals.warnAboutTooHighVolume(volume);
-
- const shouldRenderAudio = useMemo(() => {
- if (!window.remotion_audioEnabled) {
- return false;
- }
-
- if (muted) {
- return false;
- }
-
- if (volume <= 0) {
- return false;
- }
-
- return true;
- }, [muted, volume]);
-
const {fps} = videoConfig;
const {delayRender, continueRender} = useDelayRender();
@@ -80,6 +57,18 @@ export const AudioForRendering: React.FC<AudioProps> = ({
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined,
});
+ const shouldRenderAudio = (() => {
+ if (!window.remotion_audioEnabled) {
+ return false;
+ }
+
+ if (muted) {
+ return false;
+ }
+
+ return true;
+ })();
+
extractFrameViaBroadcastChannel({
src,
timeInSeconds: timestamp,
@@ -89,11 +78,26 @@ export const AudioForRendering: React.FC<AudioProps> = ({
includeAudio: shouldRenderAudio,
includeVideo: false,
isClientSideRendering: environment.isClientSideRendering,
- volume,
loop: loop ?? false,
})
- .then(({audio}) => {
- if (audio) {
+ .then(({audio, durationInSeconds: assetDurationInSeconds}) => {
+ const volumePropsFrame = frameForVolumeProp({
+ behavior: loopVolumeCurveBehavior ?? 'repeat',
+ loop: loop ?? false,
+ assetDurationInSeconds: assetDurationInSeconds ?? 0,
+ fps,
+ frame,
+ startsAt,
+ });
+ const volume = Internals.evaluateVolume({
+ volume: volumeProp,
+ frame: volumePropsFrame,
+ mediaVolume: 1,
+ });
+
+ Internals.warnAboutTooHighVolume(volume);
+
+ if (audio && volume > 0) {
registerRenderAsset({
type: 'inline-audio',
id,
@@ -127,13 +131,15 @@ export const AudioForRendering: React.FC<AudioProps> = ({
frame,
id,
logLevel,
+ loop,
+ loopVolumeCurveBehavior,
+ muted,
playbackRate,
registerRenderAsset,
- shouldRenderAudio,
src,
+ startsAt,
unregisterRenderAsset,
- volume,
- loop,
+ volumeProp,
]);
return null;
diff --git a/packages/media/src/convert-audiodata/apply-volume.ts b/packages/media/src/convert-audiodata/apply-volume.ts
new file mode 100644
index 0000000000..b0847684da
--- /dev/null
+++ b/packages/media/src/convert-audiodata/apply-volume.ts
@@ -0,0 +1,19 @@
+export const applyVolume = (array: Int16Array, volume: number) => {
+ if (volume === 1) {
+ return array;
+ }
+
+ for (let i = 0; i < array.length; i++) {
+ const newValue = array[i] * volume;
+
+ if (newValue < -32768) {
+ array[i] = -32768;
+ } else if (newValue > 32767) {
+ array[i] = 32767;
+ } else {
+ array[i] = newValue;
+ }
+ }
+
+ return array;
+};
diff --git a/packages/media/src/convert-audiodata/convert-audiodata.ts b/packages/media/src/convert-audiodata/convert-audiodata.ts
index 06d9474f2b..e34779ccfb 100644
--- a/packages/media/src/convert-audiodata/convert-audiodata.ts
+++ b/packages/media/src/convert-audiodata/convert-audiodata.ts
@@ -6,7 +6,6 @@ export type ConvertAudioDataOptions = {
trimStartInSeconds: number;
trimEndInSeconds: number;
targetNumberOfChannels: number;
- volume: number;
playbackRate: number;
};
@@ -34,7 +33,6 @@ export const convertAudioData = ({
trimStartInSeconds,
trimEndInSeconds,
targetNumberOfChannels,
- volume,
playbackRate,
}: ConvertAudioDataOptions): PcmS16AudioData => {
const {
@@ -81,7 +79,6 @@ export const convertAudioData = ({
if (
newNumberOfFrames === frameCount &&
targetNumberOfChannels === srcNumberOfChannels &&
- volume === 1 &&
playbackRate === 1
) {
return {
@@ -99,7 +96,6 @@ export const convertAudioData = ({
destination: data,
targetFrames: newNumberOfFrames,
chunkSize,
- volume,
});
const newAudioData = {
diff --git a/packages/media/src/convert-audiodata/resample-audiodata.ts b/packages/media/src/convert-audiodata/resample-audiodata.ts
index 2190758d48..42854cf34c 100644
--- a/packages/media/src/convert-audiodata/resample-audiodata.ts
+++ b/packages/media/src/convert-audiodata/resample-audiodata.ts
@@ -22,14 +22,12 @@ export const resampleAudioData = ({
destination,
targetFrames,
chunkSize,
- volume,
}: {
srcNumberOfChannels: number;
sourceChannels: Int16Array;
destination: Int16Array;
targetFrames: number;
chunkSize: number;
- volume: number;
}) => {
const getSourceValues = (
startUnfixed: number,
@@ -71,17 +69,8 @@ export const resampleAudioData = ({
}
const average = weightedSum / totalWeight;
- const averageVolume = average * volume;
- if (averageVolume < -32768) {
- return -32768;
- }
-
- if (averageVolume > 32767) {
- return 32767;
- }
-
- return averageVolume;
+ return average;
};
for (let newFrameIndex = 0; newFrameIndex < targetFrames; newFrameIndex++) {
diff --git a/packages/media/src/extract-frame-and-audio.ts b/packages/media/src/extract-frame-and-audio.ts
index 516f75bc0b..e1daee0fb0 100644
--- a/packages/media/src/extract-frame-and-audio.ts
+++ b/packages/media/src/extract-frame-and-audio.ts
@@ -11,7 +11,6 @@ export const extractFrameAndAudio = async ({
playbackRate,
includeAudio,
includeVideo,
- volume,
loop,
}: {
src: string;
@@ -21,11 +20,11 @@ export const extractFrameAndAudio = async ({
playbackRate: number;
includeAudio: boolean;
includeVideo: boolean;
- volume: number;
loop: boolean;
}): Promise<{
frame: VideoFrame | null;
audio: PcmS16AudioData | null;
+ durationInSeconds: number | null;
}> => {
const [frame, audio] = await Promise.all([
includeVideo
@@ -41,7 +40,6 @@ export const extractFrameAndAudio = async ({
src,
timeInSeconds,
durationInSeconds,
- volume,
logLevel,
loop,
playbackRate,
@@ -51,6 +49,7 @@ export const extractFrameAndAudio = async ({
return {
frame: frame?.toVideoFrame() ?? null,
- audio,
+ audio: audio?.data ?? null,
+ durationInSeconds: audio?.durationInSeconds ?? null,
};
};
diff --git a/packages/media/src/looped-frame.ts b/packages/media/src/looped-frame.ts
new file mode 100644
index 0000000000..aa12ff6133
--- /dev/null
+++ b/packages/media/src/looped-frame.ts
@@ -0,0 +1,30 @@
+import {type LoopVolumeCurveBehavior} from 'remotion';
+
+export const frameForVolumeProp = ({
+ behavior,
+ loop,
+ assetDurationInSeconds,
+ fps,
+ frame,
+ startsAt,
+}: {
+ behavior: LoopVolumeCurveBehavior;
+ loop: boolean;
+ assetDurationInSeconds: number;
+ fps: number;
+ frame: number;
+ startsAt: number;
+}) => {
+ if (!loop) {
+ return frame + startsAt;
+ }
+
+ if (behavior === 'extend') {
+ return frame + startsAt;
+ }
+
+ const assetDurationInFrames =
+ Math.floor(assetDurationInSeconds * fps) - startsAt;
+
+ return (frame % assetDurationInFrames) + startsAt;
+};
diff --git a/packages/media/src/test/browser.test.ts b/packages/media/src/test/browser.test.ts
index 214c843edf..2de5ee2ec1 100644
--- a/packages/media/src/test/browser.test.ts
+++ b/packages/media/src/test/browser.test.ts
@@ -1,5 +1,6 @@
import {assert, expect, test} from 'vitest';
import {keyframeManager} from '../caches';
+import {applyVolume} from '../convert-audiodata/apply-volume';
import {extractFrameAndAudio} from '../extract-frame-and-audio';
test('Should be able to extract a frame', async () => {
@@ -13,7 +14,6 @@ test('Should be able to extract a frame', async () => {
logLevel: 'info',
includeAudio: true,
includeVideo: true,
- volume: 1,
loop: false,
});
@@ -45,7 +45,6 @@ test('Should be able to extract the last frame', async () => {
logLevel: 'info',
includeAudio: true,
includeVideo: true,
- volume: 1,
loop: false,
});
@@ -69,7 +68,6 @@ test('Should manage the cache', async () => {
logLevel: 'info',
includeAudio: true,
includeVideo: true,
- volume: 1,
loop: false,
});
}
@@ -82,18 +80,6 @@ test('Should manage the cache', async () => {
test('Should be apply volume correctly', async () => {
await keyframeManager.clearAll();
- const {audio: audioAtHalfVolume} = await extractFrameAndAudio({
- src: '/bigbuckbunny.mp4',
- timeInSeconds: 1,
- durationInSeconds: 1 / 30,
- playbackRate: 1,
- logLevel: 'info',
- includeAudio: true,
- includeVideo: false,
- volume: 0.5,
- loop: false,
- });
-
const {audio: audioAtFullVolume, frame} = await extractFrameAndAudio({
src: '/bigbuckbunny.mp4',
timeInSeconds: 1,
@@ -102,10 +88,11 @@ test('Should be apply volume correctly', async () => {
logLevel: 'info',
includeAudio: true,
includeVideo: false,
- volume: 1,
loop: false,
});
+ const audioAtHalfVolume = applyVolume(audioAtFullVolume!.data, 0.5);
+
assert(!frame);
const totalAudioAtFullVolume = audioAtFullVolume?.data.reduce((acc, curr) => {
@@ -114,7 +101,7 @@ test('Should be apply volume correctly', async () => {
return acc + rounded;
}, 0);
assert(audioAtHalfVolume);
- const totalAudioAtHalfVolume = audioAtHalfVolume?.data.reduce(
+ const totalAudioAtHalfVolume = audioAtHalfVolume.reduce(
(acc, curr) => acc + curr,
0,
);
@@ -132,7 +119,6 @@ test('Should be able to loop', async () => {
playbackRate: 1,
includeAudio: true,
includeVideo: true,
- volume: 1,
loop: true,
});
diff --git a/packages/media/src/test/resample.test.ts b/packages/media/src/test/resample.test.ts
index 8cda08575c..1d5de02ef2 100644
--- a/packages/media/src/test/resample.test.ts
+++ b/packages/media/src/test/resample.test.ts
@@ -17,7 +17,6 @@ test('Should be able to convert audio that is on the verge', () => {
trimStartInSeconds: 0.041666666666666664,
trimEndInSeconds: 0,
targetNumberOfChannels: 1,
- volume: 1,
playbackRate: 2,
});
@@ -51,7 +50,6 @@ test('convert with playbackrate', () => {
trimStartInSeconds: 0,
trimEndInSeconds: 0,
targetNumberOfChannels: 2,
- volume: 1,
playbackRate: 2,
});
diff --git a/packages/media/src/video-extraction/extract-frame-via-broadcast-channel.ts b/packages/media/src/video-extraction/extract-frame-via-broadcast-channel.ts
index 63c42e2323..fe4b9c7e41 100644
--- a/packages/media/src/video-extraction/extract-frame-via-broadcast-channel.ts
+++ b/packages/media/src/video-extraction/extract-frame-via-broadcast-channel.ts
@@ -12,7 +12,6 @@ type ExtractFrameRequest = {
logLevel: LogLevel;
includeAudio: boolean;
includeVideo: boolean;
- volume: number;
loop: boolean;
};
@@ -22,6 +21,7 @@ type ExtractFrameResponse =
id: string;
frame: ImageBitmap | null;
audio: PcmS16AudioData | null;
+ durationInSeconds: number | null;
}
| {
type: 'response-error';
@@ -37,7 +37,7 @@ if (window.remotion_broadcastChannel && window.remotion_isMainTab) {
const data = event.data as ExtractFrameRequest;
if (data.type === 'request') {
try {
- const {frame, audio} = await extractFrameAndAudio({
+ const {frame, audio, durationInSeconds} = await extractFrameAndAudio({
src: data.src,
timeInSeconds: data.timeInSeconds,
logLevel: data.logLevel,
@@ -45,7 +45,6 @@ if (window.remotion_broadcastChannel && window.remotion_isMainTab) {
playbackRate: data.playbackRate,
includeAudio: data.includeAudio,
includeVideo: data.includeVideo,
- volume: data.volume,
loop: data.loop,
});
@@ -62,6 +61,7 @@ if (window.remotion_broadcastChannel && window.remotion_isMainTab) {
id: data.id,
frame: imageBitmap,
audio,
+ durationInSeconds: durationInSeconds ?? null,
};
window.remotion_broadcastChannel!.postMessage(response);
@@ -91,7 +91,6 @@ export const extractFrameViaBroadcastChannel = ({
includeAudio,
includeVideo,
isClientSideRendering,
- volume,
loop,
}: {
src: string;
@@ -102,11 +101,11 @@ export const extractFrameViaBroadcastChannel = ({
includeAudio: boolean;
includeVideo: boolean;
isClientSideRendering: boolean;
- volume: number;
loop: boolean;
}): Promise<{
frame: ImageBitmap | VideoFrame | null;
audio: PcmS16AudioData | null;
+ durationInSeconds: number | null;
}> => {
if (isClientSideRendering || window.remotion_isMainTab) {
return extractFrameAndAudio({
@@ -117,7 +116,6 @@ export const extractFrameViaBroadcastChannel = ({
playbackRate,
includeAudio,
includeVideo,
- volume,
loop,
});
}
@@ -127,6 +125,7 @@ export const extractFrameViaBroadcastChannel = ({
const resolvePromise = new Promise<{
frame: ImageBitmap | null;
audio: PcmS16AudioData | null;
+ durationInSeconds: number | null;
}>((resolve, reject) => {
const onMessage = (event: MessageEvent) => {
const data = event.data as ExtractFrameResponse;
@@ -139,6 +138,9 @@ export const extractFrameViaBroadcastChannel = ({
resolve({
frame: data.frame ? data.frame : null,
audio: data.audio ? data.audio : null,
+ durationInSeconds: data.durationInSeconds
+ ? data.durationInSeconds
+ : null,
});
window.remotion_broadcastChannel!.removeEventListener(
'message',
@@ -166,7 +168,6 @@ export const extractFrameViaBroadcastChannel = ({
playbackRate,
includeAudio,
includeVideo,
- volume,
loop,
};
diff --git a/packages/media/src/video/video-for-rendering.tsx b/packages/media/src/video/video-for-rendering.tsx
index cd7b3f0887..9adb99409d 100644
--- a/packages/media/src/video/video-for-rendering.tsx
+++ b/packages/media/src/video/video-for-rendering.tsx
@@ -13,6 +13,8 @@ import {
useRemotionEnvironment,
useVideoConfig,
} from 'remotion';
+import {applyVolume} from '../convert-audiodata/apply-volume';
+import {frameForVolumeProp} from '../looped-frame';
import {extractFrameViaBroadcastChannel} from '../video-extraction/extract-frame-via-broadcast-channel';
import type {VideoProps} from './props';
@@ -31,50 +33,26 @@ export const VideoForRendering: React.FC<VideoProps> = ({
style,
className,
}) => {
+ if (!src) {
+ throw new TypeError('No `src` was passed to <Video>.');
+ }
+
+ const frame = useCurrentFrame();
const absoluteFrame = Internals.useTimelinePosition();
+
const {fps} = useVideoConfig();
- const canvasRef = useRef<HTMLCanvasElement>(null);
const {registerRenderAsset, unregisterRenderAsset} = useContext(
Internals.RenderAssetManager,
);
- const frame = useCurrentFrame();
- const volumePropsFrame = Internals.useFrameForVolumeProp(
- loopVolumeCurveBehavior ?? 'repeat',
- );
- const environment = useRemotionEnvironment();
+ const startsAt = Internals.useMediaStartsAt();
const [id] = useState(() => `${Math.random()}`.replace('0.', ''));
- if (!src) {
- throw new TypeError('No `src` was passed to <Video>.');
- }
-
- const volume = Internals.evaluateVolume({
- volume: volumeProp,
- frame: volumePropsFrame,
- mediaVolume: 1,
- });
-
- Internals.warnAboutTooHighVolume(volume);
-
- const shouldRenderAudio = useMemo(() => {
- if (!window.remotion_audioEnabled) {
- return false;
- }
-
- if (muted) {
- return false;
- }
-
- if (volume <= 0) {
- return false;
- }
-
- return true;
- }, [muted, volume]);
-
+ const environment = useRemotionEnvironment();
const {delayRender, continueRender} = useDelayRender();
+ const canvasRef = useRef<HTMLCanvasElement>(null);
+
useLayoutEffect(() => {
if (!canvasRef.current) {
return;
@@ -89,6 +67,18 @@ export const VideoForRendering: React.FC<VideoProps> = ({
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined,
});
+ const shouldRenderAudio = (() => {
+ if (!window.remotion_audioEnabled) {
+ return false;
+ }
+
+ if (muted) {
+ return false;
+ }
+
+ return true;
+ })();
+
extractFrameViaBroadcastChannel({
src,
timeInSeconds: timestamp,
@@ -98,48 +88,70 @@ export const VideoForRendering: React.FC<VideoProps> = ({
includeAudio: shouldRenderAudio,
includeVideo: window.remotion_videoEnabled,
isClientSideRendering: environment.isClientSideRendering,
- volume,
loop: loop ?? false,
})
- .then(({frame: imageBitmap, audio}) => {
- if (imageBitmap) {
- onVideoFrame?.(imageBitmap);
- const context = canvasRef.current?.getContext('2d');
- if (!context) {
- return;
+ .then(
+ ({
+ frame: imageBitmap,
+ audio,
+ durationInSeconds: assetDurationInSeconds,
+ }) => {
+ if (imageBitmap) {
+ onVideoFrame?.(imageBitmap);
+ const context = canvasRef.current?.getContext('2d');
+ if (!context) {
+ return;
+ }
+
+ context.canvas.width =
+ imageBitmap instanceof ImageBitmap
+ ? imageBitmap.width
+ : imageBitmap.displayWidth;
+ context.canvas.height =
+ imageBitmap instanceof ImageBitmap
+ ? imageBitmap.height
+ : imageBitmap.displayHeight;
+ context.canvas.style.aspectRatio = `${context.canvas.width} / ${context.canvas.height}`;
+ context.drawImage(imageBitmap, 0, 0);
+
+ imageBitmap.close();
+ } else if (window.remotion_videoEnabled) {
+ cancelRender(new Error('No video frame found'));
}
- context.canvas.width =
- imageBitmap instanceof ImageBitmap
- ? imageBitmap.width
- : imageBitmap.displayWidth;
- context.canvas.height =
- imageBitmap instanceof ImageBitmap
- ? imageBitmap.height
- : imageBitmap.displayHeight;
- context.canvas.style.aspectRatio = `${context.canvas.width} / ${context.canvas.height}`;
- context.drawImage(imageBitmap, 0, 0);
-
- imageBitmap.close();
- } else if (window.remotion_videoEnabled) {
- cancelRender(new Error('No video frame found'));
- }
-
- if (audio) {
- registerRenderAsset({
- type: 'inline-audio',
- id,
- audio: Array.from(audio.data),
- sampleRate: audio.sampleRate,
- numberOfChannels: audio.numberOfChannels,
- frame: absoluteFrame,
- timestamp: audio.timestamp,
- duration: (audio.numberOfFrames / audio.sampleRate) * 1_000_000,
+ const volumePropsFrame = frameForVolumeProp({
+ behavior: loopVolumeCurveBehavior ?? 'repeat',
+ loop: loop ?? false,
+ assetDurationInSeconds: assetDurationInSeconds ?? 0,
+ fps,
+ frame,
+ startsAt,
+ });
+
+ const volume = Internals.evaluateVolume({
+ volume: volumeProp,
+ frame: volumePropsFrame,
+ mediaVolume: 1,
});
- }
- continueRender(newHandle);
- })
+ Internals.warnAboutTooHighVolume(volume);
+
+ if (audio && volume > 0) {
+ registerRenderAsset({
+ type: 'inline-audio',
+ id,
+ audio: Array.from(applyVolume(audio.data, volume)),
+ sampleRate: audio.sampleRate,
+ numberOfChannels: audio.numberOfChannels,
+ frame: absoluteFrame,
+ timestamp: audio.timestamp,
+ duration: (audio.numberOfFrames / audio.sampleRate) * 1_000_000,
+ });
+ }
+
+ continueRender(newHandle);
+ },
+ )
.catch((error) => {
cancelRender(error);
});
@@ -159,14 +171,16 @@ export const VideoForRendering: React.FC<VideoProps> = ({
frame,
id,
logLevel,
+ loop,
+ loopVolumeCurveBehavior,
+ muted,
onVideoFrame,
playbackRate,
registerRenderAsset,
- shouldRenderAudio,
src,
+ startsAt,
unregisterRenderAsset,
- volume,
- loop,
+ volumeProp,
]);
const classNameValue = useMemo(() => {