Exporting subtitles
The following ways are available for exporting captions in Remotion.
Burned-in subtitles
If you want the subtitles to be part of the video itself (burned in), render the video as usual.
npx remotion renderExporting all captions as .srt
To automatically merge all subtitles from from components which implement captionsSchema and export them as a single .srt file is not yet possible.
Follow this issue to get notified when we implement this.
Emitting a .srt file alongside the render
If you keep your captions in one place and collect them manually, you can emit a separate .srt file using the <Artifact> component together with serializeSrt().
Exporting captions as .srtconst {pages } =createTikTokStyleCaptions ({captions ,combineTokensWithinMilliseconds : 3000, }); constsrtContent =serializeSrt ({lines :pages .map (({tokens }) =>tokens .map (({text ,fromMs ,toMs }) => ({text ,startMs :fromMs ,endMs :toMs ,timestampMs : null,confidence : null, })), ), }); export constMyComp = () => { constframe =useCurrentFrame (); return ( <> {frame === 0 ? <Artifact filename ="subtitles.srt"content ={srtContent } /> : null} {/* Rest of your video content */} </> ); };
The artifact will be saved to out/[composition-id]/subtitles.srt when rendering.
Show captions only in previews
Use isRendering from useRemotionEnvironment() to keep captions visible in Studio and the Player while leaving them out of the rendered video.
MyVideo.tsximport {Video } from '@remotion/media'; import {staticFile ,useRemotionEnvironment } from 'remotion'; import {SimpleCaptions } from './SimpleCaptions'; export constMyVideo = () => { const {isRendering } =useRemotionEnvironment (); return ( <> <Video src ={staticFile ('video.mp4')} /> {isRendering ? null : <SimpleCaptions />} </> ); };
See also
- Displaying captions - Render captions in your video
- Emitting Artifacts - Full guide on artifacts
<Artifact>- Emit files during renderingserializeSrt()- Convert captions to SRT format