π₯ Make videos programmatically with React
Skills: Better handle captions
Jonny Burgere77f015ec161
diff --git a/packages/docs/docs/captions/transcribing.mdx b/packages/docs/docs/captions/transcribing.mdxindex af0a51d4ba..f1081296c5 100644--- a/packages/docs/docs/captions/transcribing.mdx+++ b/packages/docs/docs/captions/transcribing.mdx@@ -15,14 +15,14 @@ Remotion provides several built-in options for transcribing audio to generate ca## Comparison-| | [`@remotion/install-whisper-cpp`](/docs/install-whisper-cpp) | [`@remotion/whisper-web`](/docs/whisper-web) | [`@remotion/openai-whisper`](/docs/openai-whisper) |-| -------------------- | ---------------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------- |-| **Environment** | Server (Node.js) | Client (Browser) | Cloud (API) |-| **Speed** | Fast (depends on hardware) | Slow (WASM overhead) | Fast |-| **Cost** | Free | Free | Paid (OpenAI API pricing) |-| **Offline support** | β | β | β |-| **No server needed** | β | β | β |-| **Convert function** | [`convertToCaptions()`](/docs/install-whisper-cpp/convert-to-captions) | [`toCaptions()`](/docs/whisper-web/to-captions) | [`openaiWhisperApiToCaptions()`](/docs/openai-whisper/openai-whisper-api-to-captions) |+| | [`@remotion/install-whisper-cpp`](/docs/install-whisper-cpp) | [`@remotion/whisper-web`](/docs/whisper-web) | [`@remotion/openai-whisper`](/docs/openai-whisper) |+| -------------------- | ------------------------------------------------------------ | ----------------------------------------------- | ------------------------------------------------------------------------------------- |+| **Environment** | Server (Node.js) | Client (Browser) | Cloud (API) |+| **Speed** | Fast (depends on hardware) | Slow (WASM overhead) | Fast |+| **Cost** | Free | Free | Paid (OpenAI API pricing) |+| **Offline support** | β | β | β |+| **No server needed** | β | β | β |+| **Convert function** | [`toCaptions()`](/docs/install-whisper-cpp/to-captions) | [`toCaptions()`](/docs/whisper-web/to-captions) | [`openaiWhisperApiToCaptions()`](/docs/openai-whisper/openai-whisper-api-to-captions) |## The `Caption` typediff --git a/packages/docs/docs/install-whisper-cpp/index.mdx b/packages/docs/docs/install-whisper-cpp/index.mdxindex c2272c29e8..e4fe20f11a 100644--- a/packages/docs/docs/install-whisper-cpp/index.mdx+++ b/packages/docs/docs/install-whisper-cpp/index.mdx@@ -4,7 +4,7 @@ title: '@remotion/install-whisper-cpp'crumb: 'Transcribe audio locally'----<AvailableFrom v="4.0.115" />+# @remotion/install-whisper-cpp<AvailableFrom v="4.0.115" />With [Whisper.cpp](https://github.com/ggerganov/whisper.cpp), you can transcribe audio locally on your machine.This package provides easy to use cross-platform functions to install Whisper.cpp and a model.@@ -19,7 +19,8 @@ Install Whisper `1.5.5` (the latest version at the time of writing that we find```tsx twoslash title="install-whisper.cpp"import path from 'path';-import {downloadWhisperModel, installWhisperCpp, transcribe, convertToCaptions} from '@remotion/install-whisper-cpp';+import {downloadWhisperModel, installWhisperCpp, transcribe, toCaptions} from '@remotion/install-whisper-cpp';+import fs from 'fs';const to = path.join(process.cwd(), 'whisper.cpp');@@ -37,7 +38,7 @@ await downloadWhisperModel({// import {execSync} from 'child_process';// execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y');-const {transcription} = await transcribe({+const whisperCppOutput = await transcribe({model: 'medium.en',whisperPath: to,whisperCppVersion: '1.5.5',@@ -45,19 +46,12 @@ const {transcription} = await transcribe({tokenLevelTimestamps: true,});-for (const token of transcription) {- console.log(token.timestamps.from, token.timestamps.to, token.text);-}-// Optional: Apply our recommended postprocessing-const {captions} = convertToCaptions({- transcription,- combineTokensWithinMilliseconds: 200,+const {captions} = toCaptions({+ whisperCppOutput,});-for (const line of captions) {- console.log(line.text, line.startInSeconds);-}+fs.writeFileSync('captions.json', JSON.stringify(captions, null, 2));```## Functionsdiff --git a/packages/docs/docs/standalone.mdx b/packages/docs/docs/standalone.mdxindex 6adfc3e6f9..832b84a9e4 100644--- a/packages/docs/docs/standalone.mdx+++ b/packages/docs/docs/standalone.mdx@@ -102,4 +102,5 @@ Unbolded APIs are licensed under the MIT license.- [installWhisperCpp\(\)](/docs/install-whisper-cpp/install-whisper-cpp)- [transcribe\(\)](/docs/install-whisper-cpp/transcribe)- [convertToCaptions\(\)](/docs/install-whisper-cpp/convert-to-captions)+- [toCaptions\(\)](/docs/install-whisper-cpp/to-captions)- [downloadWhisperModel\(\)](/docs/install-whisper-cpp/download-whisper-model)diff --git a/packages/install-whisper-cpp/src/index.ts b/packages/install-whisper-cpp/src/index.tsindex 78269c6d76..4c06465d5f 100644--- a/packages/install-whisper-cpp/src/index.ts+++ b/packages/install-whisper-cpp/src/index.ts@@ -1,14 +1,20 @@-export {- ConvertToCaptionCaption,- convertToCaptions,-} from './convert-to-captions';+export {ConvertToCaptionCaption} from './convert-to-captions';export type {OnProgress} from './download';-export {WhisperModel, downloadWhisperModel} from './download-whisper-model';+export {downloadWhisperModel, WhisperModel} from './download-whisper-model';export {installWhisperCpp} from './install-whisper-cpp';export type {Language} from './languages';export {toCaptions} from './to-captions';export {+ transcribe,TranscribeOnProgress,TranscriptionJson,- transcribe,} from './transcribe';++import {convertToCaptions as deprecatedConvertToCaptions} from './convert-to-captions';++/**+ *+ * @deprecated convertToCaptions() has been deprecated as of Remotion v4.0.216.+ * Use the toCaptions() function instead.+ */+export const convertToCaptions = deprecatedConvertToCaptions;diff --git a/packages/skills/skills/remotion/SKILL.md b/packages/skills/skills/remotion/SKILL.mdindex b215feceeb..3d28fd1869 100644--- a/packages/skills/skills/remotion/SKILL.md+++ b/packages/skills/skills/remotion/SKILL.md@@ -9,6 +9,10 @@ metadata:Use this skills whenever you are dealing with Remotion code to obtain the domain-specific knowledge.+## Captions++When dealing with captions or subtitles, load the [./rules/subtitles.md](./rules/subtitles.md) file for more information.+## How to useRead individual rule files for detailed explanations and code examples:@@ -21,7 +25,6 @@ Read individual rule files for detailed explanations and code examples:- [rules/can-decode.md](rules/can-decode.md) - Check if a video can be decoded by the browser using Mediabunny- [rules/charts.md](rules/charts.md) - Chart and data visualization patterns for Remotion- [rules/compositions.md](rules/compositions.md) - Defining compositions, stills, folders, default props and dynamic metadata-- [rules/display-captions.md](rules/display-captions.md) - Displaying captions in Remotion with TikTok-style pages and word highlighting- [rules/extract-frames.md](rules/extract-frames.md) - Extract frames from videos at specific timestamps using Mediabunny- [rules/fonts.md](rules/fonts.md) - Loading Google Fonts and local fonts in Remotion- [rules/get-audio-duration.md](rules/get-audio-duration.md) - Getting the duration of an audio file in seconds with Mediabunny@@ -29,7 +32,6 @@ Read individual rule files for detailed explanations and code examples:- [rules/get-video-duration.md](rules/get-video-duration.md) - Getting the duration of a video file in seconds with Mediabunny- [rules/gifs.md](rules/gifs.md) - Displaying GIFs synchronized with Remotion's timeline- [rules/images.md](rules/images.md) - Embedding images in Remotion using the Img component-- [rules/import-srt-captions.md](rules/import-srt-captions.md) - Importing .srt subtitle files into Remotion using @remotion/captions- [rules/lottie.md](rules/lottie.md) - Embedding Lottie animations in Remotion- [rules/measuring-dom-nodes.md](rules/measuring-dom-nodes.md) - Measuring DOM element dimensions in Remotion- [rules/measuring-text.md](rules/measuring-text.md) - Measuring text dimensions, fitting text to containers, and checking overflow@@ -37,7 +39,6 @@ Read individual rule files for detailed explanations and code examples:- [rules/tailwind.md](rules/tailwind.md) - Using TailwindCSS in Remotion- [rules/text-animations.md](rules/text-animations.md) - Typography and text animation patterns for Remotion- [rules/timing.md](rules/timing.md) - Interpolation curves in Remotion - linear, easing, spring animations-- [rules/transcribe-captions.md](rules/transcribe-captions.md) - Transcribing audio to generate captions in Remotion- [rules/transitions.md](rules/transitions.md) - Scene transition patterns for Remotion- [rules/transparent-videos.md](rules/transparent-videos.md) - Rendering out a video with transparency- [rules/trimming.md](rules/trimming.md) - Trimming patterns for Remotion - cut the beginning or end of animationsdiff --git a/packages/skills/skills/remotion/rules/audio.md b/packages/skills/skills/remotion/rules/audio.mdindex 48086ec91e..1097c70e86 100644--- a/packages/skills/skills/remotion/rules/audio.md+++ b/packages/skills/skills/remotion/rules/audio.md@@ -13,10 +13,7 @@ First, the @remotion/media package needs to be installed.If it is not installed, use the following command:```bash-npx remotion add @remotion/media # If project uses npm-bunx remotion add @remotion/media # If project uses bun-yarn remotion add @remotion/media # If project uses yarn-pnpm exec remotion add @remotion/media # If project uses pnpm+npx remotion add @remotion/media```## Importing Audiodiff --git a/packages/skills/skills/remotion/rules/display-captions.md b/packages/skills/skills/remotion/rules/display-captions.mdindex 1f70b702ae..f9cb0f05d7 100644--- a/packages/skills/skills/remotion/rules/display-captions.md+++ b/packages/skills/skills/remotion/rules/display-captions.md@@ -7,18 +7,55 @@ metadata:# Displaying captions in Remotion-This guide explains how to display captions in Remotion, assuming you already have captions in the `Caption` format.+This guide explains how to display captions in Remotion, assuming you already have captions in the [`Caption`](https://www.remotion.dev/docs/captions/caption) format.## Prerequisites-First, the @remotion/captions package needs to be installed.+Read [Transcribing audio](transcribe-captions.md) for how to generate captions.++First, the [`@remotion/captions`](https://www.remotion.dev/docs/captions) package needs to be installed.If it is not installed, use the following command:```bash-npx remotion add @remotion/captions # If project uses npm-bunx remotion add @remotion/captions # If project uses bun-yarn remotion add @remotion/captions # If project uses yarn-pnpm exec remotion add @remotion/captions # If project uses pnpm+npx remotion add @remotion/captions+```++## Fetching captions++First, fetch your captions JSON file. Use [`useDelayRender()`](https://www.remotion.dev/docs/use-delay-render) to hold the render until the captions are loaded:++```tsx+import { useState, useEffect, useCallback } from "react";+import { AbsoluteFill, staticFile, useDelayRender } from "remotion";+import type { Caption } from "@remotion/captions";++export const MyComponent: React.FC = () => {+ const [captions, setCaptions] = useState<Caption[] | null>(null);+ const { delayRender, continueRender, cancelRender } = useDelayRender();+ const [handle] = useState(() => delayRender());++ const fetchCaptions = useCallback(async () => {+ try {+ // Assuming captions.json is in the public/ folder.+ const response = await fetch(staticFile("captions123.json"));+ const data = await response.json();+ setCaptions(data);+ continueRender(handle);+ } catch (e) {+ cancelRender(e);+ }+ }, [continueRender, cancelRender, handle]);++ useEffect(() => {+ fetchCaptions();+ }, [fetchCaptions]);++ if (!captions) {+ return null;+ }++ return <AbsoluteFill>{/* Render captions here */}</AbsoluteFill>;+};```## Creating pages@@ -26,16 +63,16 @@ pnpm exec remotion add @remotion/captions # If project uses pnpmUse `createTikTokStyleCaptions()` to group captions into pages. The `combineTokensWithinMilliseconds` option controls how many words appear at once:```tsx-import {useMemo} from 'react';-import {createTikTokStyleCaptions} from '@remotion/captions';-import type {Caption} from '@remotion/captions';+import { useMemo } from "react";+import { createTikTokStyleCaptions } from "@remotion/captions";+import type { Caption } from "@remotion/captions";// How often captions should switch (in milliseconds)// Higher values = more words per page// Lower values = fewer words (more word-by-word)const SWITCH_CAPTIONS_EVERY_MS = 1200;-const {pages} = useMemo(() => {+const { pages } = useMemo(() => {return createTikTokStyleCaptions({captions,combineTokensWithinMilliseconds: SWITCH_CAPTIONS_EVERY_MS,@@ -48,11 +85,11 @@ const {pages} = useMemo(() => {Map over the pages and render each one in a `<Sequence>`. Calculate the start frame and duration from the page timing:```tsx-import {Sequence, useVideoConfig, AbsoluteFill} from 'remotion';-import type {TikTokPage} from '@remotion/captions';+import { Sequence, useVideoConfig, AbsoluteFill } from "remotion";+import type { TikTokPage } from "@remotion/captions";const CaptionedContent: React.FC = () => {- const {fps} = useVideoConfig();+ const { fps } = useVideoConfig();return (<AbsoluteFill>@@ -84,19 +121,28 @@ const CaptionedContent: React.FC = () => {};```+## White-space preservation++The captions are whitespace sensitive. You should include spaces in the `text` field before each word. Use `whiteSpace: "pre"` to preserve the whitespace in the captions.++## Separate component for captions++Put captioning logic in a separate component.+Make a new file for it.+## Word highlightingA caption page contains `tokens` which you can use to highlight the currently spoken word:```tsx-import {AbsoluteFill, useCurrentFrame, useVideoConfig} from 'remotion';-import type {TikTokPage} from '@remotion/captions';+import { AbsoluteFill, useCurrentFrame, useVideoConfig } from "remotion";+import type { TikTokPage } from "@remotion/captions";-const HIGHLIGHT_COLOR = '#39E508';+const HIGHLIGHT_COLOR = "#39E508";-const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {+const CaptionPage: React.FC<{ page: TikTokPage }> = ({ page }) => {const frame = useCurrentFrame();- const {fps} = useVideoConfig();+ const { fps } = useVideoConfig();// Current time relative to the start of the sequenceconst currentTimeMs = (frame / fps) * 1000;@@ -104,8 +150,8 @@ const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {const absoluteTimeMs = page.startMs + currentTimeMs;return (- <AbsoluteFill style={{justifyContent: 'center', alignItems: 'center'}}>- <div style={{fontSize: 80, fontWeight: 'bold', whiteSpace: 'pre'}}>+ <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>+ <div style={{ fontSize: 80, fontWeight: "bold", whiteSpace: "pre" }}>{page.tokens.map((token) => {const isActive =token.fromMs <= absoluteTimeMs && token.toMs > absoluteTimeMs;@@ -113,7 +159,7 @@ const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {return (<spankey={token.fromMs}- style={{color: isActive ? HIGHLIGHT_COLOR : 'white'}}+ style={{ color: isActive ? HIGHLIGHT_COLOR : "white" }}>{token.text}</span>@@ -124,3 +170,15 @@ const CaptionPage: React.FC<{page: TikTokPage}> = ({page}) => {);};```++## Display captions alongside video content++By default, put the captions alongside the video content, so the captions are in sync.+For each video, make a new captions JSON file.++```tsx+<AbsoluteFill>+ <Video src={staticFile("video.mp4")} />+ <CaptionPage page={page} />+</AbsoluteFill>+```diff --git a/packages/skills/skills/remotion/rules/gifs.md b/packages/skills/skills/remotion/rules/gifs.mdindex d067c759ea..042647f61c 100644--- a/packages/skills/skills/remotion/rules/gifs.md+++ b/packages/skills/skills/remotion/rules/gifs.md@@ -12,17 +12,23 @@ metadata:Use `<AnimatedImage>` to display a GIF, APNG, AVIF or WebP image synchronized with Remotion's timeline:```tsx-import {AnimatedImage, staticFile} from 'remotion';+import { AnimatedImage, staticFile } from "remotion";export const MyComposition = () => {- return <AnimatedImage src={staticFile('animation.gif')} width={500} height={500} />;+ return (+ <AnimatedImage src={staticFile("animation.gif")} width={500} height={500} />+ );};```Remote URLs are also supported (must have CORS enabled):```tsx-<AnimatedImage src="https://example.com/animation.gif" width={500} height={500} />+<AnimatedImage+ src="https://example.com/animation.gif"+ width={500}+ height={500}+/>```## Sizing and fit@@ -70,12 +76,12 @@ Use the `style` prop for additional CSS (use `width` and `height` props for sizi```tsx<AnimatedImage- src={staticFile('animation.gif')}+ src={staticFile("animation.gif")}width={500}height={500}style={{borderRadius: 20,- position: 'absolute',+ position: "absolute",top: 100,left: 50,}}@@ -87,28 +93,25 @@ Use the `style` prop for additional CSS (use `width` and `height` props for siziUse `getGifDurationInSeconds()` from `@remotion/gif` to get the duration of a GIF.```bash-npx remotion add @remotion/gif # If project uses npm-bunx remotion add @remotion/gif # If project uses bun-yarn remotion add @remotion/gif # If project uses yarn-pnpm exec remotion add @remotion/gif # If project uses pnpm+npx remotion add @remotion/gif``````tsx-import {getGifDurationInSeconds} from '@remotion/gif';-import {staticFile} from 'remotion';+import { getGifDurationInSeconds } from "@remotion/gif";+import { staticFile } from "remotion";-const duration = await getGifDurationInSeconds(staticFile('animation.gif'));+const duration = await getGifDurationInSeconds(staticFile("animation.gif"));console.log(duration); // e.g. 2.5```This is useful for setting the composition duration to match the GIF:```tsx-import {getGifDurationInSeconds} from '@remotion/gif';-import {staticFile, CalculateMetadataFunction} from 'remotion';+import { getGifDurationInSeconds } from "@remotion/gif";+import { staticFile, CalculateMetadataFunction } from "remotion";const calculateMetadata: CalculateMetadataFunction = async () => {- const duration = await getGifDurationInSeconds(staticFile('animation.gif'));+ const duration = await getGifDurationInSeconds(staticFile("animation.gif"));return {durationInFrames: Math.ceil(duration * 30),};@@ -127,11 +130,11 @@ pnpm exec remotion add @remotion/gif # If project uses pnpm``````tsx-import {Gif} from '@remotion/gif';-import {staticFile} from 'remotion';+import { Gif } from "@remotion/gif";+import { staticFile } from "remotion";export const MyComposition = () => {- return <Gif src={staticFile('animation.gif')} width={500} height={500} />;+ return <Gif src={staticFile("animation.gif")} width={500} height={500} />;};```diff --git a/packages/skills/skills/remotion/rules/import-srt-captions.md b/packages/skills/skills/remotion/rules/import-srt-captions.mdindex 0b9c5bb303..333c962131 100644--- a/packages/skills/skills/remotion/rules/import-srt-captions.md+++ b/packages/skills/skills/remotion/rules/import-srt-captions.md@@ -9,6 +9,8 @@ metadata:If you have an existing `.srt` subtitle file, you can import it into Remotion using `parseSrt()` from `@remotion/captions`.+If you don't have a .srt file, read [Transcribing audio](transcribe-captions.md) for how to generate captions instead.+## PrerequisitesFirst, the @remotion/captions package needs to be installed.@@ -26,21 +28,21 @@ pnpm exec remotion add @remotion/captions # If project uses pnpmUse `staticFile()` to reference an `.srt` file in your `public` folder, then fetch and parse it:```tsx-import {useState, useEffect, useCallback} from 'react';-import {AbsoluteFill, staticFile, useDelayRender} from 'remotion';-import {parseSrt} from '@remotion/captions';-import type {Caption} from '@remotion/captions';+import { useState, useEffect, useCallback } from "react";+import { AbsoluteFill, staticFile, useDelayRender } from "remotion";+import { parseSrt } from "@remotion/captions";+import type { Caption } from "@remotion/captions";export const MyComponent: React.FC = () => {const [captions, setCaptions] = useState<Caption[] | null>(null);- const {delayRender, continueRender, cancelRender} = useDelayRender();+ const { delayRender, continueRender, cancelRender } = useDelayRender();const [handle] = useState(() => delayRender());const fetchCaptions = useCallback(async () => {try {- const response = await fetch(staticFile('subtitles.srt'));+ const response = await fetch(staticFile("subtitles.srt"));const text = await response.text();- const {captions: parsed} = parseSrt({input: text});+ const { captions: parsed } = parseSrt({ input: text });setCaptions(parsed);continueRender(handle);} catch (e) {diff --git a/packages/skills/skills/remotion/rules/subtitles.md b/packages/skills/skills/remotion/rules/subtitles.mdnew file mode 100644index 0000000000..2291eef305--- /dev/null+++ b/packages/skills/skills/remotion/rules/subtitles.md@@ -0,0 +1,36 @@+---+name: subtitles+description: subtitles and caption rules+metadata:+ tags: subtitles, captions, remotion, json+---++All captions must be processed in JSON. The captions must use the `Caption` type which is the following:++```ts+import type { Caption } from "@remotion/captions";+```++This is the definition:++```ts+type Caption = {+ text: string;+ startMs: number;+ endMs: number;+ timestampMs: number | null;+ confidence: number | null;+};+```++## Generating captions++To transcribe video and audio files to generate captions, load the [./transcribe-captions.md](./transcribe-captions.md) file for more instructions.++## Displaying captions++To display captions in your video, load the [./display-captions.md](./display-captions.md) file for more instructions.++## Importing captions++To import captions from a .srt file, load the [./import-srt-captions.md](./import-srt-captions.md) file for more instructions.diff --git a/packages/skills/skills/remotion/rules/transcribe-captions.md b/packages/skills/skills/remotion/rules/transcribe-captions.mdindex b338486bc1..ba649d5749 100644--- a/packages/skills/skills/remotion/rules/transcribe-captions.md+++ b/packages/skills/skills/remotion/rules/transcribe-captions.md@@ -7,13 +7,64 @@ metadata:# Transcribing audio-Remotion provides several built-in options for transcribing audio to generate captions:+To transcribe audio to generate captions in Remotion, you can use the [`transcribe()`](https://www.remotion.dev/docs/install-whisper-cpp/transcribe) function from the [`@remotion/install-whisper-cpp`](https://www.remotion.dev/docs/install-whisper-cpp) package.-- `@remotion/install-whisper-cpp` - Transcribe locally on a server using Whisper.cpp. Fast and free, but requires server infrastructure.- https://remotion.dev/docs/install-whisper-cpp+## Prerequisites-- `@remotion/whisper-web` - Transcribe in the browser using WebAssembly. No server needed and free, but slower due to WASM overhead.- https://remotion.dev/docs/whisper-web+First, the @remotion/install-whisper-cpp package needs to be installed.+If it is not installed, use the following command:-- `@remotion/openai-whisper` - Use OpenAI Whisper API for cloud-based transcription. Fast and no server needed, but requires payment.- https://remotion.dev/docs/openai-whisper/openai-whisper-api-to-captions+```bash+npx remotion add @remotion/install-whisper-cpp+```++## Transcribing++Make a Node.js script to download Whisper.cpp and a model, and transcribe the audio.++```ts+import path from "path";+import {+ downloadWhisperModel,+ installWhisperCpp,+ transcribe,+ toCaptions,+} from "@remotion/install-whisper-cpp";+import fs from "fs";++const to = path.join(process.cwd(), "whisper.cpp");++await installWhisperCpp({+ to,+ version: "1.5.5",+});++await downloadWhisperModel({+ model: "medium.en",+ folder: to,+});++// Convert the audio to a 16KHz wav file first if needed:+// import {execSync} from 'child_process';+// execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y');++const whisperCppOutput = await transcribe({+ model: "medium.en",+ whisperPath: to,+ whisperCppVersion: "1.5.5",+ inputPath: "/path/to/audio123.wav",+ tokenLevelTimestamps: true,+});++// Optional: Apply our recommended postprocessing+const { captions } = toCaptions({+ whisperCppOutput,+});++// Write it to the public/ folder so it can be fetched from Remotion+fs.writeFileSync("captions123.json", JSON.stringify(captions, null, 2));+```++Transcribe each clip individually and create multiple JSON files.++See [Displaying captions](display-captions.md) for how to display the captions in Remotion.