🎥 Make videos programmatically with React
Update captioning.mdx
JonnyBurgera7196def57d9
diff --git a/packages/docs/docs/editor-starter/captioning.mdx b/packages/docs/docs/editor-starter/captioning.mdxindex 90ef733ec7..38d20d2cd4 100644--- a/packages/docs/docs/editor-starter/captioning.mdx+++ b/packages/docs/docs/editor-starter/captioning.mdx@@ -5,49 +5,70 @@ sidebar_label: Captionscrumb: Editor Starter----# Captioning+The Editor Starter comes with a method to generate captions for videos and audio assets.+It uses the OpenAI Whisper API by default.-Generate word-accurate subtitles for video and audio assets using AI-powered transcription, and display them as animated captions (e.g., TikTok-style word-by-word animations) in the editor's timeline and canvas. For implementation details, refer to the source code in `src/editor/captioning/`.+For implementation details, refer to the source code in [`src/editor/captioning`](https://github.com/remotion-dev/editor-starter/tree/main/src/editor/captioning).In the Editor Starter, captions are treated as a first-class [item type](/docs/editor-starter/tracks-items-assets#items), similar to videos, images, or audio. This allows them to be manipulated like any other layer in the timeline and canvas.-## Features+## Setup with OpenAI Whisper (recommended)++To generate captions using OpenAI's Whisper model, add your OpenAI key to the `.env` file:++```+OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx+```++This enables server-side transcription if the [`/api/captions`](/docs/editor-starter/backend-routes#post-apicaptions) backend route is present.-### Text style customization+Click "Generate Captions" on a video or audio layer:-- Font-- Text color-- Highlighed word color-- Opacity+1. The audio is extracted client-side.+2. It uploads it to [`/api/captions`](/docs/editor-starter/backend-routes#post-apicaptions) and transcribes it via OpenAI (note: [A limit of 25MB applies](/docs/editor-starter/features-not-included#captioning-long-audio-files))+3. It converts OpenAI's response into Remotion's [`Caption`](/docs/captions/caption) type and adds it to the timeline as a [`CaptionsItem`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter+type+captionsitem&type=code).-### Timing customization+## Editing+The [inspector](/docs/editor-starter/tracks-items-assets#inspectors) allows users to edit the following properties of captions by default:++- Individual tokens+- Typography: Font, text color, highlighted word color, opacity- Page duration- Adjust timings of individual words-### Automated creation of pages+## Automated creation of pages-Captions are automatically split into "pages" for easier management. Pages are timed groups of words or sentences that fit nicely on screen. This is achieved by using `createTikTokStyleCaptions` from [@remotion/openai-whisper](/docs/captions) package.+Captions are automatically split into "pages" for easier management. Pages are timed groups of words or sentences that fit nicely on screen. This is achieved by using [`createTikTokStyleCaptions`](/docs/captions/create-tiktok-style-captions) from [`@remotion/captions`](/docs/captions) package.+## Alternatives-## Setup with OpenAI Whisper (recommended)+### `@remotion/whisper-web`-To generate captions using OpenAI's Whisper model, add your OpenAI key to the `.env` file:-```-OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx-```+You can replace the OpenAI Whisper API with [`@remotion/whisper-web`](/docs/whisper-web) for local, in-browser transcription.+This eliminates the need for an OpenAI key and S3 fetches for transcription, but you'll still need to handle audio loading locally.++Caveats:++- Performance: Transcription runs on the CPU in the browser, which can be significantly slower than GPU-accelerated options like OpenAI's cloud service.+- Model size: Smaller models (e.g., 'tiny') are faster but less accurate; larger ones require more memory and space.+- You need to [enable cross-origin isolation](/docs/whisper-web/can-use-whisper-web#important-considerations) for your app.++### `@remotion/install-whisper-cpp`++You can use [`@remotion/install-whisper-cpp`](/docs/whisper-cpp) to transcribe audio on a Node.js server.++Caveats:-This enables server-side transcription. Click "Generate Captions" on a video or audio layer:-1. The editor fetches the audio.-2. It transcribes it via OpenAI.-3. It converts OpenAI's response into Remotion's `Captions` type and adds it to the timeline as a `CaptionsItem`.+- You are responsible for hosting and scaling the server, which can be costly and complex.+### More alternatives-## Alternative: in-browser local transcription+Any way of transcription can be used.+We recommend that you convert the captions to the [`Caption`](/docs/captions/caption) shape so that rendering and editing the captions does not need to be refactored.-If you prefer not to use OpenAI (e.g., for privacy, cost, or offline support), you can integrate [@remotion/whisper-web](/docs/whisper-web) for local, in-browser transcription using a WebAssembly-based Whisper model. This eliminates the need for an OpenAI key and S3 fetches for transcription, but you'll still need to handle audio loading locally.+## See also-### Caveats-- **Performance**: Transcription runs on the CPU in the browser, which can be significantly slower than GPU-accelerated options like OpenAI's cloud service. Expect longer processing times for larger audio files (e.g., several minutes vs. seconds).-- **Model size**: Smaller models (e.g., 'tiny') are faster but less accurate; larger ones require more memory and time.-- **Browser compatibility**: Works in modern browsers supporting WebAssembly, but test on your target devices.+- [`@remotion/captions`](/docs/captions)+- [`@remotion/whisper-web`](/docs/whisper-web)+- [`@remotion/install-whisper-cpp`](/docs/whisper-cpp)