Remotion Captions — Subtítulos Animados para Video
Agrega subtítulos y leyendas animadas a videos de Remotion desde archivos .SRT. Resaltados palabra por palabra al estilo TikTok, efectos de karaoke y más.
Resumen
- Repositorio: github.com/ahgsql/remotion-subtitles
- Lenguaje: TypeScript / React
- Licencia: Código Abierto
- Instalación:
npm install remotion-subtitles - Requiere: Proyecto Remotion
Configuración
npm install remotion-subtitles
Uso Básico
Desde Archivo SRT
import { useSubtitles, SubtitleSequence } from "remotion-subtitles";
export const CaptionedVideo: React.FC = () => {
const subtitles = useSubtitles("./subtitles.srt");
return (
<AbsoluteFill>
<Video src={staticFile("video.mp4")} />
<SubtitleSequence subtitles={subtitles} />
</AbsoluteFill>
);
};
Formato SRT
1
00:00:00,000 --> 00:00:02,500
Bienvenido a Custom Agents
2
00:00:02,500 --> 00:00:05,000
La plataforma de correo electrónico impulsada por IA
3
00:00:05,000 --> 00:00:08,000
que gestiona tu bandeja de entrada automáticamente
Estilizado de Leyendas
<SubtitleSequence
subtitles={subtitles}
style={{
position: "absolute",
bottom: 80,
left: 0,
right: 0,
textAlign: "center",
fontSize: 42,
fontWeight: "bold",
color: "white",
textShadow: "2px 2px 8px rgba(0,0,0,0.8)",
fontFamily: "Inter, sans-serif",
}}
/>
Resaltado Palabra por Palabra (Estilo TikTok)
import { useCurrentFrame, interpolate } from "remotion";
export const WordHighlightCaption: React.FC<{
words: { text: string; startFrame: number; endFrame: number }[];
}> = ({ words }) => {
const frame = useCurrentFrame();
return (
<div style={{
position: "absolute",
bottom: 100,
width: "100%",
textAlign: "center",
display: "flex",
justifyContent: "center",
gap: 8,
flexWrap: "wrap",
padding: "0 60px",
}}>
{words.map((word, i) => {
const isActive = frame >= word.startFrame && frame <= word.endFrame;
const scale = isActive
? interpolate(frame, [word.startFrame, word.startFrame + 3], [1, 1.15], { extrapolateRight: "clamp" })
: 1;
return (
<span
key={i}
style={{
fontSize: 48,
fontWeight: 800,
color: isActive ? "#FFD700" : "white",
textShadow: isActive
? "0 0 20px rgba(255,215,0,0.5)"
: "2px 2px 4px rgba(0,0,0,0.8)",
transform: `scale(${scale})`,
transition: "color 0.1s",
display: "inline-block",
}}
>
{word.text}
</span>
);
})}
</div>
);
};
Temporización Manual de Leyendas
Si no tienes un archivo SRT, define las leyendas manualmente:
const captions = [
{ text: "Bienvenido a Custom Agents", startFrame: 0, endFrame: 75 },
{ text: "Automatización de correo electrónico con IA", startFrame: 80, endFrame: 150 },
{ text: "Crea agentes en minutos", startFrame: 155, endFrame: 240 },
];
export const ManualCaptions: React.FC = () => {
const frame = useCurrentFrame();
const current = captions.find(
(c) => frame >= c.startFrame && frame <= c.endFrame
);
if (!current) return null;
const progress = interpolate(
frame,
[current.startFrame, current.startFrame + 10],
[0, 1],
{ extrapolateRight: "clamp" }
);
return (
<div style={{
position: "absolute",
bottom: 80,
width: "100%",
textAlign: "center",
opacity: progress,
transform: `translateY(${(1 - progress) * 10}px)`,
}}>
<span style={{
fontSize: 44,
fontWeight: 700,
color: "white",
backgroundColor: "rgba(0,0,0,0.6)",
padding: "8px 24px",
borderRadius: 8,
}}>
{current.text}
</span>
</div>
);
};
Mejores Prácticas
- Posicionar en la parte inferior — La colocación estándar de los subtítulos es en la parte inferior central
- Usar contraste — Texto blanco con sombra oscura o fondo semitransparente
- Fuente grande — Mínimo 40-50px para legibilidad en video
- Frases cortas — Máximo 2 líneas, 6-8 palabras por leyenda
- Margen de temporización — Iniciar las leyendas 2-3 fotogramas antes del audio
- Animación de entrada — Desvanecimiento/deslizamiento sutil hacia adentro, sin animación al salir
- Negrita — Peso de fuente 700+ para legibilidad en video
Fuentes
- remotion-subtitles: github.com/ahgsql/remotion-subtitles
- Plantilla Remotion Audiogram: github.com/remotion-dev/template-audiogram