subs

package
v0.0.0-...-5214aa6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVTTCPayload

func ParseVTTCPayload(data []byte, cueStart int, cueEnd int) (string, error)

func WebvttTimeString

func WebvttTimeString(time int) string

Types

type Body

type Body struct {
	Divisions []Division `xml:"div"`
}

type CueSetting

type CueSetting struct {
	Align            string `webvtt:"align"`
	Line             string `webvtt:"line"`
	Position         string `webvtt:"position"`
	Size             string `webvtt:"size"`
	SnapToLines      string `webvtt:"snap-to-lines"`
	Vertical         string `webvtt:"vertical"`
	WritingMode      string `webvtt:"writing-mode"`
	BackgroundColor  string `webvtt:"background-color"`
	Color            string `webvtt:"color"`
	Font             string `webvtt:"font"`
	FontFamily       string `webvtt:"font-family"`
	FontSize         string `webvtt:"font-size"`
	FontStyle        string `webvtt:"font-style"`
	FontVariant      string `webvtt:"font-variant"`
	FontWeight       string `webvtt:"font-weight"`
	TextDecoration   string `webvtt:"text-decoration"`
	TextShadow       string `webvtt:"text-shadow"`
	WordSpacing      string `webvtt:"word-spacing"`
	LineHeight       string `webvtt:"line-height"`
	LetterSpacing    string `webvtt:"letter-spacing"`
	Padding          string `webvtt:"padding"`
	Animate          string `webvtt:"animate"`
	AnimateColor     string `webvtt:"animate-color"`
	AnimateDirection string `webvtt:"animate-direction"`
	AnimateFill      string `webvtt:"animate-fill"`
	AnimateName      string `webvtt:"animate-name"`
	AnimateRepeat    string `webvtt:"animate-repeat"`
	AnimateState     string `webvtt:"animate-state"`
	AnimateTiming    string `webvtt:"animate-timing"`
	Lang             string `webvtt:"lang"`
	Ruby             string `webvtt:"ruby"`
	RubyAlign        string `webvtt:"ruby-align"`
	RubyOverhang     string `webvtt:"ruby-overhang"`
	RubyPosition     string `webvtt:"ruby-position"`
	RubySpan         string `webvtt:"ruby-span"`
	Voice            string `webvtt:"voice"`
	VoiceDuration    string `webvtt:"voice-duration"`
	VoiceRate        string `webvtt:"voice-rate"`
	VoicePitch       string `webvtt:"voice-pitch"`
	VoiceRange       string `webvtt:"voice-range"`
	VoiceVolume      string `webvtt:"voice-volume"`
}

type Division

type Division struct {
	Region     string      `xml:"region,attr"`
	Paragraphs []Paragraph `xml:"p"`
}
type Head struct {
	Metadata Metadata `xml:"metadata"`
	Styling  Styling  `xml:"styling"`
	Layout   Layout   `xml:"layout"`
}

type Layout

type Layout struct {
	Regions []Region `xml:"region"`
}

type Metadata

type Metadata struct {
	Title       string `xml:"title"`
	Description string `xml:"desc"`
	Copyright   string `xml:"copyright"`
}

type Paragraph

type Paragraph struct {
	Begin  string `xml:"begin,attr"`
	End    string `xml:"end,attr"`
	Region string `xml:"region,attr"`
	ID     string `xml:"id,attr"`
	Role   string `xml:"role,attr"`

	Text string `xml:",innerxml"`

	Span []Span `xml:"span"`
	Br   string `xml:"br"`
}

func (*Paragraph) MarshalXML

func (p *Paragraph) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Region

type Region struct {
	ID    string `xml:"id,attr"`
	Style string `xml:"style,attr"`
}

func (Region) MarshalXML

func (r Region) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Span

type Span struct {
	Text      string `xml:",chardata"`
	Color     string `xml:"color,attr"`
	TextAlign string `xml:"textAlign,attr"`
}

func (Span) MarshalXML

func (s Span) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Style

type Style struct {
	Attrs []xml.Attr `xml:",attr"`
}

func (*Style) GetAttr

func (s *Style) GetAttr(attrName string) string

func (*Style) MarshalXML

func (s *Style) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Style) UnmarshalXML

func (s *Style) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Styling

type Styling struct {
	Styles []Style `xml:"style"`
}

func (*Styling) ToWebVTT

func (s *Styling) ToWebVTT() []string

type TtmlDocument

type TtmlDocument struct {
	XMLName xml.Name   `xml:"tt"`
	Attrs   []xml.Attr `xml:",attr"`
	Lang    string     `xml:"lang,attr,omitempty"`
	Head    Head       `xml:"head"`
	Body    Body       `xml:"body"`
}

func NewTtml

func NewTtml(data []byte) (*TtmlDocument, error)

func OpenTtml

func OpenTtml(filename string) (*TtmlDocument, error)

func (*TtmlDocument) MarshalXML

func (d *TtmlDocument) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*TtmlDocument) Merge

func (doc *TtmlDocument) Merge(other *TtmlDocument) *TtmlDocument

Merge does an in-memory merge of 2 TTML documents

func (*TtmlDocument) MergeFromData

func (doc *TtmlDocument) MergeFromData(data []byte) *TtmlDocument

MergeFromData does an in-memory merge of 2 TTML documents, using the byte representation of a second doc Note that the timestamps aren't realigned, so the second doc should be a subset of the first.

func (*TtmlDocument) SaveAsVTT

func (doc *TtmlDocument) SaveAsVTT(outPath string) error

SaveAsVTT saves the TTML document to the specified file in WebVTT format. This is a convenience method that calls ToVTT internally.

func (*TtmlDocument) ToVTT

func (doc *TtmlDocument) ToVTT(w io.Writer) error

ToVTT writes the TTML document to the specified writer in WebVTT format.

func (*TtmlDocument) Write

func (doc *TtmlDocument) Write(w io.Writer) error

Write writes the TTML document to the specified writer.

type VTTCueBoxContent

type VTTCueBoxContent struct {
	Size    int
	Content string
}

func ExtractAtomWebVTT

func ExtractAtomWebVTT(buf []byte) ([]VTTCueBoxContent, error)

ExtractAtomWebVTT extracts the WebVTT cues from an mp4 atom buffer timestamps are missing and should be capture using the trun box entries.

Jump to

Keyboard shortcuts

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