Documentation ¶
Index ¶
- Variables
- type Color
- type Item
- type Justification
- type Line
- type LineItem
- type Metadata
- type Options
- type Region
- type SSAOptions
- type Style
- type StyleAttributes
- type Subtitles
- func (s *Subtitles) Add(d time.Duration)
- func (s *Subtitles) ApplyLinearCorrection(actual1, desired1, actual2, desired2 time.Duration)
- func (s Subtitles) Duration() time.Duration
- func (s *Subtitles) ForceDuration(d time.Duration, addDummyItem bool)
- func (s *Subtitles) Fragment(f time.Duration)
- func (s Subtitles) IsEmpty() bool
- func (s *Subtitles) Merge(i *Subtitles)
- func (s *Subtitles) Optimize()
- func (s *Subtitles) Order()
- func (s *Subtitles) RemoveStyling()
- func (s *Subtitles) Unfragment()
- func (s Subtitles) Write(dst string) (err error)
- func (s Subtitles) WriteToSSA(o io.Writer) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( ColorBlack = &Color{} ColorBlue = &Color{Blue: 255} ColorCyan = &Color{Blue: 255, Green: 255} ColorGray = &Color{Blue: 128, Green: 128, Red: 128} ColorGreen = &Color{Green: 128} ColorLime = &Color{Green: 255} ColorMagenta = &Color{Blue: 255, Red: 255} ColorMaroon = &Color{Red: 128} ColorOlive = &Color{Green: 128, Red: 128} ColorPurple = &Color{Blue: 128, Red: 128} ColorRed = &Color{Red: 255} ColorSilver = &Color{Blue: 192, Green: 192, Red: 192} ColorTeal = &Color{Blue: 128, Green: 128} ColorYellow = &Color{Green: 255, Red: 255} ColorWhite = &Color{Blue: 255, Green: 255, Red: 255} )
Colors
var ( ErrInvalidExtension = errors.New("astisub: invalid extension") ErrNoSubtitlesToWrite = errors.New("astisub: no subtitles to write") )
Errors
var ( JustificationUnchanged = Justification(1) JustificationLeft = Justification(2) JustificationCentered = Justification(3) JustificationRight = Justification(4) )
var (
BytesBOM = []byte{239, 187, 191}
)
Bytes
var Now = func() time.Time { return time.Now() }
Now allows testing functions using it
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct {
Alpha, Blue, Green, Red uint8
}
Color represents a color
func (*Color) TTMLString ¶
TTMLString expresses the color as a TTML string
type Item ¶
type Item struct { Comments []string Index int EndAt time.Duration InlineStyle *StyleAttributes Lines []Line Region *Region StartAt time.Duration Style *Style }
Item represents a text to show between 2 time boundaries with formatting
type Justification ¶
type Justification int
type LineItem ¶
type LineItem struct { InlineStyle *StyleAttributes Style *Style Text string }
LineItem represents a formatted line item
type Metadata ¶
type Metadata struct { Comments []string Framerate int Language string SSACollisions string SSAOriginalEditing string SSAOriginalScript string SSAOriginalTiming string SSAOriginalTranslation string SSAPlayDepth *int SSAPlayResX, SSAPlayResY *int SSAScriptType string SSAScriptUpdatedBy string SSASynchPoint string SSATimer *float64 SSAUpdateDetails string SSAWrapStyle string STLCountryOfOrigin string STLCreationDate *time.Time STLDisplayStandardCode string STLMaximumNumberOfDisplayableCharactersInAnyTextRow *int STLMaximumNumberOfDisplayableRows *int STLPublisher string STLRevisionDate *time.Time STLSubtitleListReferenceCode string STLTimecodeStartOfProgramme time.Duration Title string TTMLCopyright string }
Metadata represents metadata TODO Merge attributes
type Region ¶
type Region struct { ID string InlineStyle *StyleAttributes Style *Style }
Region represents a subtitle's region
type SSAOptions ¶
SSAOptions
type Style ¶
type Style struct { ID string InlineStyle *StyleAttributes Style *Style }
Style represents a subtitle's style
type StyleAttributes ¶
type StyleAttributes struct { SSAAlignment *int SSAAlphaLevel *float64 SSAAngle *float64 // degrees SSABackColour *Color SSABold *bool SSABorderStyle *int SSAEffect string SSAEncoding *int SSAFontName string SSAFontSize *float64 SSAItalic *bool SSALayer *int SSAMarginLeft *int // pixels SSAMarginRight *int // pixels SSAMarginVertical *int // pixels SSAMarked *bool SSAOutline *float64 // pixels SSAOutlineColour *Color SSAPrimaryColour *Color SSAScaleX *float64 // % SSAScaleY *float64 // % SSASecondaryColour *Color SSAShadow *float64 // pixels SSASpacing *float64 // pixels SSAStrikeout *bool SSAUnderline *bool STLBoxing *bool STLItalics *bool STLJustification *Justification //STLPosition *STLPosition STLUnderline *bool TeletextColor *Color TeletextDoubleHeight *bool TeletextDoubleSize *bool TeletextDoubleWidth *bool TeletextSpacesAfter *int TeletextSpacesBefore *int // TODO Use pointers with real types below TTMLBackgroundColor *string // https://htmlcolorcodes.com/fr/ TTMLColor *string TTMLDirection *string TTMLDisplay *string TTMLDisplayAlign *string TTMLExtent *string TTMLFontFamily *string TTMLFontSize *string TTMLFontStyle *string TTMLFontWeight *string TTMLLineHeight *string TTMLOpacity *string TTMLOrigin *string TTMLOverflow *string TTMLPadding *string TTMLShowBackground *string TTMLTextAlign *string TTMLTextDecoration *string TTMLTextOutline *string TTMLUnicodeBidi *string TTMLVisibility *string TTMLWrapOption *string TTMLWritingMode *string TTMLZIndex *int WebVTTAlign string WebVTTItalics bool WebVTTLine string WebVTTLines int WebVTTPosition string WebVTTRegionAnchor string WebVTTScroll string WebVTTSize string WebVTTVertical string WebVTTViewportAnchor string WebVTTWidth string }
StyleAttributes represents style attributes
type Subtitles ¶
type Subtitles struct { Items []*Item Metadata *Metadata Regions map[string]*Region Styles map[string]*Style }
Subtitles represents an ordered list of items with formatting
func ReadFromSSA ¶
ReadFromSSA parses an .ssa content
func ReadFromSSAWithOptions ¶
func ReadFromSSAWithOptions(i io.Reader, opts SSAOptions) (o *Subtitles, err error)
ReadFromSSAWithOptions parses an .ssa content
func (*Subtitles) Add ¶
Add adds a duration to each time boundaries. As in the time package, duration can be negative.
func (*Subtitles) ApplyLinearCorrection ¶
ApplyLinearCorrection applies linear correction
func (*Subtitles) ForceDuration ¶
ForceDuration updates the subtitles duration. If requested duration is bigger, then we create a dummy item. If requested duration is smaller, then we remove useless items and we cut the last item or add a dummy item.
func (*Subtitles) RemoveStyling ¶
func (s *Subtitles) RemoveStyling()
RemoveStyling removes the styling from the subtitles