subtext

package
v0.3.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ASSHeader = "[Script Info]\n; Script generated by Ether\nScriptType: v4.00+\nPlayResX: 384\nPlayResY: 288\nScaledBorderAndShadow: yes\nYCbCr Matrix: None\n\n" +
	"[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n" +
	"Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,1\n\n" +
	"[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n"

ASSHeader is the script header RenderASS writes: FFmpeg's own header for a converted text track (PlayRes 384x288, one "Default" style), so a player that restyles "Default" (Plex Web's subtitle colour, size and position settings) treats it like the converted stream PMS sends.

Variables

This section is empty.

Functions

func AcceptsUploadFormat

func AcceptsUploadFormat(format string) bool

AcceptsUploadFormat is the Plex Web upload format check: case-sensitive on the wire. PMS accepts srt/ass/ssa/smi/txt/psb; Ether also accepts vtt.

func CleanCueText

func CleanCueText(s string) string

CleanCueText folds cue text to the markup the cue model carries: <i>, <b>, <u> and <font color="…">. WebVTT class (<c.white>), voice (<v …>) and language (<lang …>) spans, ruby markup, in-cue timestamp tags, ASS override blocks and every other tag are dropped, keeping the text they wrapped (a ruby annotation's own text goes with its tags). Without this, an SRT converted from WebVTT captions — Netflix-derived OpenSubtitles files are the common case — serves its <c.…> tags literally to SRT players that know nothing of WebVTT classes (#616).

func FormatASSTimestamp

func FormatASSTimestamp(d time.Duration) string

FormatASSTimestamp formats a duration as an ASS timestamp, H:MM:SS.cc.

func HasForeignTags

func HasForeignTags(text, format string) bool

HasForeignTags reports whether stored subtitle text carries markup the named format ("srt" or "vtt") must not be served with: any tag outside that format's set, or an in-cue WebVTT timestamp tag. Cached files written before cue text was cleaned at parse time are caught by this on read and re-rendered, so no migration pass is needed (#616).

func RenderASS

func RenderASS(cues []Cue) string

RenderASS renders cues as an ASS script with ASSHeader: <i>, <b> and <u> become override tags, other markup is dropped and line breaks are \N.

func RenderSRT

func RenderSRT(cues []Cue) string

RenderSRT renders cues as SubRip. Cue text is cleaned here as well as at parse time, so cues built by other paths (extracted embedded tracks, cached cue windows) cannot leak WebVTT spans into SRT either.

func RenderVTT

func RenderVTT(cues []Cue) string

RenderVTT renders cues as WebVTT.

Types

type Cue

type Cue struct {
	Start, End time.Duration
	Text       string
}

Cue is one subtitle cue.

func ParseCues

func ParseCues(text string) ([]Cue, error)

ParseCues parses SRT or WebVTT text (already UTF-8) into cues.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL