parseSrt()v4.0.216
Parses the contents of a SubRip file (.srt
) and returns an array of Caption
items.
Example usagetsx
import {parseSrt } from '@remotion/captions';constinput = `100:00:00,000 --> 00:00:02,500Welcome to the Example Subtitle File!200:00:03,000 --> 00:00:06,000This is a demonstration of SRT subtitles.300:00:07,000 --> 00:00:10,500You 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,},]*/
Example usagetsx
import {parseSrt } from '@remotion/captions';constinput = `100:00:00,000 --> 00:00:02,500Welcome to the Example Subtitle File!200:00:03,000 --> 00:00:06,000This is a demonstration of SRT subtitles.300:00:07,000 --> 00:00:10,500You 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,},]*/
API
input
The contents of a .srt
file as a string
.
Return value
An object with the following properties:
captions
An array of Caption
items.