Subtitle sources are used to add subtitle data to output subtitle tracks. All subtitle sources extend the baseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Vanilagy/mediabunny/llms.txt
Use this file to discover all available pages before exploring further.
SubtitleSource class.
TextSubtitleSource
Parses subtitle text from a subtitle file format and adds the cues to the output subtitle track.Constructor
The subtitle format/codec used in the text being added. Supported values:
'srt'- SubRip subtitle format'webvtt'- WebVTT subtitle format'ass'- Advanced SubStation Alpha format
Methods
add
Parses subtitle text according to the specified codec and adds it to the output track. You don’t have to add the entire subtitle file at once - you can provide it in chunks.The subtitle text to parse and add. Can be the entire subtitle file content or a chunk of it.
Resolves when the output is ready to receive more samples. Await this to respect backpressure.
close
Closes the source, preventing future subtitle cues from being added and signaling that no more data will be added to this track.Calling
close() is optional but recommended after adding the last subtitle chunk for improved performance and reduced memory usage.Subtitle formats
SubRip (.srt)
The SubRip format is a simple, widely-supported subtitle format. Each subtitle consists of:- A sequential number
- Timing information (start —> end)
- The subtitle text
- A blank line