View Source Subtitle.Cue (kim_subtitle v0.1.0)
Cue manipulation. It is aware of WebVTT tags in the text field.
Summary
Functions
Transforms cue into a temporarily ordered sequence of cues, preserving their duration. It adds 1ms between overapping cues.
Cuts the duration to at most max_duration
.
Returns the duration of the cue.
Extend cue to last at least min_duration
.
May produce overlapping cues that can be fixed by calling __MODULE__.align/1
.
Merges two cues given the following conditions
Splits a cue into multiple single-line cues.
Removes overlapping cues. This function is useful after merging HLS segments, as a cue might be repeated in multiple segments.
Creates a list of paragraphs obtained from the text of the cues.
Merges together cues that have no silence in between. Silence
is configurable through the opts.silence
option, which defaults
to 1ms.
Lazy version of to_paragraphs/2.
Types
@type merge_option() :: {:max_lines, pos_integer()} | {:max_duration, pos_integer()}
@type split_option() :: {:min_length, pos_integer()} | {:max_length, pos_integer()}
@type t() :: %Subtitle.Cue{ from: non_neg_integer(), id: String.t(), text: String.t(), to: pos_integer() }
@type to_paragraphs_option() :: {:silence, pos_integer()}
Functions
Transforms cue into a temporarily ordered sequence of cues, preserving their duration. It adds 1ms between overapping cues.
@spec cut(t(), pos_integer()) :: t()
Cuts the duration to at most max_duration
.
@spec duration(t()) :: pos_integer()
Returns the duration of the cue.
@spec extend(t(), non_neg_integer()) :: t()
Extend cue to last at least min_duration
.
May produce overlapping cues that can be fixed by calling __MODULE__.align/1
.
@spec merge(t(), t(), [merge_option()]) :: {:ok, t()} | {:error, atom()}
Merges two cues given the following conditions:
- The number of lines do not exceed
opts.max_lines
- The distance between the two cues is less than
@max_distance_ms
. - The duration of the cues does not exceed
opts.max_duration
The cues must be sorted by time, should not overlap and should not contain new lines.
@spec split(t(), [split_option()]) :: [t()]
Splits a cue into multiple single-line cues.
Removes overlapping cues. This function is useful after merging HLS segments, as a cue might be repeated in multiple segments.
@spec to_paragraphs([t()], [to_paragraphs_option()]) :: [ {:text | :speaker, String.t()} ]
Creates a list of paragraphs obtained from the text of the cues.
Merges together cues that have no silence in between. Silence
is configurable through the opts.silence
option, which defaults
to 1ms.
@spec to_paragraphs_lazy(Enumerable.t(), Keyword.t()) :: Stream.t()
Lazy version of to_paragraphs/2.