Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.
Python ai-toolsauto-captionscaptionscliffmpegmcpmcp-serveropusclip-alternativepodcast-clipspodcastsshortform-videovertical-videowhisper
Fix Remotion DM Sans timeout that broke nightly e2e (#118)
Nika Siradze7dc48193e9aa
diff --git a/remotion/src/Root.tsx b/remotion/src/Root.tsxindex b5ceac3..0cc2512 100644--- a/remotion/src/Root.tsx+++ b/remotion/src/Root.tsx@@ -1,26 +1,28 @@-import "@fontsource/dm-sans/400.css";-import "@fontsource/dm-sans/700.css";import React from "react";import { Composition, continueRender, delayRender, getInputProps } from "remotion";import { CaptionedClip } from "./CaptionedClip";import { Bookend } from "./Bookend";import { STYLES } from "./types";import type { Word } from "./types";+import dmSans400 from "@fontsource/dm-sans/files/dm-sans-latin-400-normal.woff2";+import dmSans700 from "@fontsource/dm-sans/files/dm-sans-latin-700-normal.woff2";-// @fontsource only injects @font-face CSS and the browser fetches lazily, so-// early frames can rasterize with fallback glyphs. Force the load and block-// rendering on it. fonts.load() is used because fonts.ready resolves-// immediately while no rendered text references the family yet.const fontsReady = delayRender("Waiting for DM Sans");-Promise.all([- document.fonts.load("400 16px 'DM Sans'"),- document.fonts.load("700 16px 'DM Sans'"),-])- .then(() => document.fonts.ready)++const loadFace = (source: string, weight: string) =>+ new FontFace("DM Sans", `url(${source})`, {+ weight,+ style: "normal",+ display: "swap",+ })+ .load()+ .then((face) => {+ document.fonts.add(face);+ });++Promise.all([loadFace(dmSans400 as string, "400"), loadFace(dmSans700 as string, "700")]).then(() => continueRender(fontsReady)).catch((err) => {- // An unfetchable or unparseable woff2 must degrade to the fallback font. An- // uncleared delayRender fails every frame instead, killing the whole render.console.warn("DM Sans failed to load, falling back:", err);continueRender(fontsReady);});@@ -33,7 +35,6 @@ const inputProps = getInputProps() as {faceY?: number | null;durationInFrames?: number;fps?: number;- // Bookend propsbookendMode?: "intro" | "outro";bookendTitle?: string;bookendHandle?: string;diff --git a/remotion/test-render.mjs b/remotion/test-render.mjsindex 6e321b0..61f31ab 100644--- a/remotion/test-render.mjs+++ b/remotion/test-render.mjs@@ -95,8 +95,8 @@ async function main() {...composition,durationInFrames,fps,- width: 2160,- height: 3840,+ width: 1080,+ height: 1920,},serveUrl: bundleLocation,codec: "h264",diff --git a/remotion/webpack-override.mjs b/remotion/webpack-override.mjsindex 4c05915..0f119f1 100644--- a/remotion/webpack-override.mjs+++ b/remotion/webpack-override.mjs@@ -1,12 +1,3 @@-/**- * Remotion's esbuild-loader reads a tsconfig via `require('typescript')` unless- * `tsconfigRaw` is already set. The runtime lives under the user's home dir, so- * Node walks up and resolves whatever TypeScript it finds there — a TypeScript 7- * install has no `ts.sys` and hard-crashes the bundle. Pinning tsconfigRaw skips- * that lookup. Empty matches the shipped default: the runtime bundle has no- * typescript, and every composition imports React, so esbuild's classic JSX- * transform is correct.- */const TSCONFIG_RAW = { compilerOptions: {} };const pinTsconfig = (entry) =>@@ -17,12 +8,21 @@ const pinTsconfig = (entry) =>? { ...entry, options: { ...entry.options, tsconfigRaw: TSCONFIG_RAW } }: entry;+const isFontAssetRule = (rule) =>+ rule &&+ rule.type === "asset/resource" &&+ rule.test instanceof RegExp &&+ String(rule.test).includes("woff");+export const webpackOverride = (config) => ({...config,module: {...config.module,- rules: (config.module?.rules ?? []).map((rule) =>- Array.isArray(rule?.use) ? { ...rule, use: rule.use.map(pinTsconfig) } : rule,- ),+ rules: (config.module?.rules ?? []).map((rule) => {+ if (isFontAssetRule(rule)) {+ return { ...rule, type: "asset/inline" };+ }+ return Array.isArray(rule?.use) ? { ...rule, use: rule.use.map(pinTsconfig) } : rule;+ }),},});diff --git a/remotion/webpack-override.test.mjs b/remotion/webpack-override.test.mjsindex 9f5a97c..ea8cec5 100644--- a/remotion/webpack-override.test.mjs+++ b/remotion/webpack-override.test.mjs@@ -47,4 +47,23 @@ describe("webpackOverride", () => {const config = webpackOverride(remotionLikeConfig());expect(config.module.rules[0].use[0]).toEqual({ loader: "css-loader" });});++ it("inlines woff font assets so Remotion tabs do not fetch them", () => {+ const config = webpackOverride({+ module: {+ rules: [+ {+ test: /\.(woff(2)?|otf|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,+ type: "asset/resource",+ },+ {+ test: /\.(png|svg|jpg)$/,+ type: "asset/resource",+ },+ ],+ },+ });+ expect(config.module.rules[0].type).toBe("asset/inline");+ expect(config.module.rules[1].type).toBe("asset/resource");+ });});