Capítulo 674 de 988

Chapter 674: parseSrt()

Core Idea

Parses the contents of a SubRip file (. srt) and returns an array of Caption items.

Key Concepts

  • API
  • input
  • Return value
  • captions
  • See also

Code Examples

const input = `
1
00:00:00,000 --> 00:00:02,500
Welcome to the Example Subtitle File!

2
00:00:03,000 --> 00:00:06,000
This is a demonstration of SRT subtitles.

3
00:00:07,000 --> 00:00:10,500
You can use SRT files to add subtitles to your videos.
`.trim();

const {captions} = parseSrt({input});

/* captions = [
  {
    confidence: 1,
    endMs: 2500,
    startMs: 0,
    text: 'Welcome to the Example Subtitle File!',
    timestampMs: 1250,
  },
  {
    confidence: 1,
    endMs: 6000,
    startMs: 3000,
    text: 'This is a demonstration of SRT subtitles.',
    timestampMs: 4500,
  },
  {
    confidence: 1,
    endMs: 10500,
    startMs: 7000,
    text: 'You can use SRT files to add subtitles to your videos.',
    timestampMs: 8750,
  },
]
*/
  • What it demonstrates: Usage pattern for parseSrt() from the official docs.

Key Takeaways

  1. Understand api when working with parseSrt().
  2. Understand input when working with parseSrt().
  3. Understand return value when working with parseSrt().
  4. Understand captions when working with parseSrt().
  5. Understand see also when working with parseSrt().

Connects To

  • api: related page in the Captions (@remotion/captions) section.
  • Caption: related page in the Captions (@remotion/captions) section.
  • Create Tiktok Style Captions: related page in the Captions (@remotion/captions) section.