Skip to content

🎥 Make videos programmatically with React

Remotion Recorder: Move to `@remotion/media`, fix warnings

JonnyBurger85f1b9f8a3ef
diff --git a/bun.lock b/bun.lock
index 6818532665..094bbc5d33 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1705,6 +1705,7 @@
"@remotion/install-whisper-cpp": "workspace:*",
"@remotion/lambda": "workspace:*",
"@remotion/layout-utils": "workspace:*",
+ "@remotion/media": "workspace:*",
"@remotion/media-parser": "workspace:*",
"@remotion/media-utils": "workspace:*",
"@remotion/renderer": "workspace:*",
diff --git a/packages/template-recorder/config/fonts.ts b/packages/template-recorder/config/fonts.ts
index ccbd06698b..5fba232657 100644
--- a/packages/template-recorder/config/fonts.ts
+++ b/packages/template-recorder/config/fonts.ts
@@ -14,9 +14,15 @@ import {
} from "@remotion/google-fonts/Inter";
import { cancelRender, continueRender, delayRender } from "remotion";
-const regular = loadRegular();
-const monospace = loadMonospace();
-const endcard = loadEndcard();
+const regular = loadRegular("normal", {
+ weights: ["600", "700"],
+});
+const monospace = loadMonospace("normal", {
+ weights: ["500"],
+});
+const endcard = loadEndcard("normal", {
+ weights: ["500"],
+});
export const waitForFonts = async () => {
await regular.waitUntilDone();
diff --git a/packages/template-recorder/package.json b/packages/template-recorder/package.json
index 116c4c4f77..aa5138d11e 100644
--- a/packages/template-recorder/package.json
+++ b/packages/template-recorder/package.json
@@ -29,6 +29,7 @@
"@remotion/renderer": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/streaming": "workspace:*",
+ "@remotion/media": "workspace:*",
"@remotion/studio": "workspace:*",
"@remotion/studio-server": "workspace:*",
"@remotion/zod-types": "workspace:*",
diff --git a/packages/template-recorder/remotion/captions/editor/CaptionOverlay.tsx b/packages/template-recorder/remotion/captions/editor/CaptionOverlay.tsx
index 9d6326913b..c4a8fead31 100644
--- a/packages/template-recorder/remotion/captions/editor/CaptionOverlay.tsx
+++ b/packages/template-recorder/remotion/captions/editor/CaptionOverlay.tsx
@@ -1,7 +1,8 @@
import { Caption } from "@remotion/captions";
import React, { useEffect, useMemo, useState } from "react";
import type { StaticFile } from "remotion";
-import { useDelayRender, watchStaticFile } from "remotion";
+import { useDelayRender, useRemotionEnvironment } from "remotion";
+import { watchStaticFile } from "@remotion/studio";
import type { Theme } from "../../../config/themes";
import { CaptionsEditor } from "./CaptionsEditor";
import type { CaptionsContextType } from "./captions-provider";
@@ -27,7 +28,13 @@ export const CaptionOverlay: React.FC<{
return { open: subEditorOpen, setOpen: setSubEditorOpen };
}, [subEditorOpen, setSubEditorOpen]);
+ const env = useRemotionEnvironment();
+
useEffect(() => {
+ if (!env.isStudio) {
+ return;
+ }
+
// Don't listen to filesystem changes
// if the sub editor is open
if (subEditorOpen) {
diff --git a/packages/template-recorder/remotion/helpers/refresh-on-public-folder-change.ts b/packages/template-recorder/remotion/helpers/refresh-on-public-folder-change.ts
index d363b75352..1c228a6251 100644
--- a/packages/template-recorder/remotion/helpers/refresh-on-public-folder-change.ts
+++ b/packages/template-recorder/remotion/helpers/refresh-on-public-folder-change.ts
@@ -4,7 +4,7 @@ import {
watchPublicFolder,
} from "@remotion/studio";
import { useEffect, useState } from "react";
-import { StaticFile } from "remotion";
+import { StaticFile, useRemotionEnvironment } from "remotion";
import {
ALTERNATIVE1_PREFIX,
ALTERNATIVE2_PREFIX,
@@ -32,8 +32,13 @@ export const useRefreshOnPublicFolderChange = (compositionId: string) => {
const [staticFiles, setStaticFiles] = useState(() =>
filterForCurrentComposition(getStaticFiles(), compositionId),
);
+ const env = useRemotionEnvironment();
useEffect(() => {
+ if (!env.isStudio) {
+ return;
+ }
+
const { cancel } = watchPublicFolder(() => {
const newStaticFiles = filterForCurrentComposition(
getStaticFiles(),
diff --git a/packages/template-recorder/remotion/scenes/BRoll/ScaleDownBRoll.tsx b/packages/template-recorder/remotion/scenes/BRoll/ScaleDownBRoll.tsx
index 97aaea2eec..03e1f6c476 100644
--- a/packages/template-recorder/remotion/scenes/BRoll/ScaleDownBRoll.tsx
+++ b/packages/template-recorder/remotion/scenes/BRoll/ScaleDownBRoll.tsx
@@ -1,5 +1,5 @@
import React, { useMemo } from "react";
-import { Img, interpolate, OffthreadVideo, useVideoConfig } from "remotion";
+import { Img, interpolate, useVideoConfig } from "remotion";
import type { BRollWithDimensions } from "../../../config/scenes";
import { fitElementSizeInContainer } from "../../layout/fit-element";
import type {
@@ -8,6 +8,7 @@ import type {
Rect,
} from "../../layout/layout-types";
import { ScaleDownIfBRollRequiresIt } from "./ScaleDownWithBRoll";
+import { Video } from "@remotion/media";
export const ScaleDownBRoll: React.FC<{
bRollEnterDirection: BRollEnterDirection;
@@ -102,7 +103,7 @@ export const ScaleDownBRoll: React.FC<{
<Img src={bRoll.source} style={style} />
) : null}
{bRoll.type === "video" ? (
- <OffthreadVideo src={bRoll.source} muted style={style} />
+ <Video src={bRoll.source} muted style={style} />
) : null}
</ScaleDownIfBRollRequiresIt>
</div>
diff --git a/packages/template-recorder/remotion/scenes/VideoScene/Display.tsx b/packages/template-recorder/remotion/scenes/VideoScene/Display.tsx
index f803d678f0..68eae3c88f 100644
--- a/packages/template-recorder/remotion/scenes/VideoScene/Display.tsx
+++ b/packages/template-recorder/remotion/scenes/VideoScene/Display.tsx
@@ -1,5 +1,5 @@
import React, { useMemo } from "react";
-import { OffthreadVideo, useCurrentFrame, useVideoConfig } from "remotion";
+import { useCurrentFrame, useVideoConfig } from "remotion";
import type { CanvasLayout } from "../../../config/layout";
import type {
SceneAndMetadata,
@@ -8,6 +8,7 @@ import type {
import { getDisplayPosition } from "../../animations/display-transitions";
import { BRollStack } from "../BRoll/BRollStack";
import { ScaleDownIfBRollRequiresIt } from "../BRoll/ScaleDownWithBRoll";
+import { Video } from "@remotion/media";
const outer: React.CSSProperties = {
position: "absolute",
@@ -81,7 +82,7 @@ export const Display: React.FC<{
bRollType={scene.layout.bRollType}
frame={frame}
>
- <OffthreadVideo
+ <Video
trimBefore={startFrame}
trimAfter={trimAfter}
src={scene.cameras.display.src}
diff --git a/packages/template-recorder/remotion/scenes/VideoScene/VideoWithBlur.tsx b/packages/template-recorder/remotion/scenes/VideoScene/VideoWithBlur.tsx
index 335e6024ba..04d7c25eae 100644
--- a/packages/template-recorder/remotion/scenes/VideoScene/VideoWithBlur.tsx
+++ b/packages/template-recorder/remotion/scenes/VideoScene/VideoWithBlur.tsx
@@ -1,12 +1,9 @@
import React, { useMemo } from "react";
-import {
- AbsoluteFill,
- OffthreadVideo,
- RemotionOffthreadVideoProps,
-} from "remotion";
+import { AbsoluteFill, RemotionOffthreadVideoProps } from "remotion";
import type { Dimensions } from "../../../config/layout";
import { getBlurLayout } from "../../layout/blur";
import type { Layout } from "../../layout/layout-types";
+import { Video } from "@remotion/media";
// An image that if it cannot fill out the canvas, will have a background-blurred replica
export const VideoWithBlur: React.FC<
@@ -26,7 +23,7 @@ export const VideoWithBlur: React.FC<
if (!enableBlur) {
return (
<AbsoluteFill>
- <OffthreadVideo
+ <Video
style={{
objectFit: "cover",
...outerStyle,
@@ -40,8 +37,8 @@ export const VideoWithBlur: React.FC<
return (
<AbsoluteFill style={outerStyle}>
- {needsBlur ? <OffthreadVideo style={blurStyle} {...props} muted /> : null}
- <OffthreadVideo style={innerStyle} {...props} />
+ {needsBlur ? <Video style={blurStyle} {...props} muted /> : null}
+ <Video style={innerStyle} {...props} />
</AbsoluteFill>
);
};