Skip to content

🎥 Make videos programmatically with React

fix infinite loops during rendering

Jonny Burgerdcc64c7fd231
diff --git a/packages/core/src/audio/AudioForRendering.tsx b/packages/core/src/audio/AudioForRendering.tsx
index b2bbde6a80..af3f7d031d 100644
--- a/packages/core/src/audio/AudioForRendering.tsx
+++ b/packages/core/src/audio/AudioForRendering.tsx
@@ -23,6 +23,11 @@ export const AudioForRendering: React.FC<RemotionAudioProps> = (props) => {
[props.muted, props.src, sequenceContext]
);
+ const volume = evaluateVolume({
+ volume: props.volume,
+ frame: sequenceFrame,
+ });
+
useEffect(() => {
if (!props.src) {
throw new Error('No src passed');
@@ -37,10 +42,7 @@ export const AudioForRendering: React.FC<RemotionAudioProps> = (props) => {
src: props.src,
id,
sequenceFrame,
- volume: evaluateVolume({
- volume: props.volume,
- frame: sequenceFrame,
- }),
+ volume,
isRemote: isRemoteAsset(props.src),
});
return () => unregisterAsset(id);
@@ -52,7 +54,7 @@ export const AudioForRendering: React.FC<RemotionAudioProps> = (props) => {
id,
unregisterAsset,
sequenceFrame,
- props.volume,
+ volume,
]);
return null;
diff --git a/packages/core/src/video/VideoForRendering.tsx b/packages/core/src/video/VideoForRendering.tsx
index 0eafb77ddc..87744f9f53 100644
--- a/packages/core/src/video/VideoForRendering.tsx
+++ b/packages/core/src/video/VideoForRendering.tsx
@@ -13,6 +13,7 @@ import {RemotionVideoProps} from './props';
export const VideoForRendering: React.FC<RemotionVideoProps> = ({
onError,
+ volume: volumeProp,
...props
}) => {
const frame = useCurrentFrame();
@@ -42,6 +43,11 @@ export const VideoForRendering: React.FC<RemotionVideoProps> = ({
throw new Error('No video config found');
}
+ const volume = evaluateVolume({
+ volume: volumeProp,
+ frame,
+ });
+
useEffect(() => {
if (!props.src) {
throw new Error('No src passed');
@@ -56,10 +62,7 @@ export const VideoForRendering: React.FC<RemotionVideoProps> = ({
src: props.src,
id,
sequenceFrame: frame,
- volume: evaluateVolume({
- volume: props.volume,
- frame,
- }),
+ volume,
isRemote: isRemoteAsset(props.src),
});
@@ -71,7 +74,7 @@ export const VideoForRendering: React.FC<RemotionVideoProps> = ({
id,
unregisterAsset,
frame,
- props.volume,
+ volume,
]);
useEffect(() => {