Documentation
¶
Overview ¶
Package subtitle finds a video's subtitle tracks, embedded or in files next to it, and serves the text ones as WebVTT for the web player.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
Converter turns subtitle tracks into WebVTT and caches the results, so each track is converted once per version of its file.
func NewConverter ¶
func (*Converter) Serve ¶
func (c *Converter) Serve(w http.ResponseWriter, r *http.Request, videoPath string, t Track, all []Track)
Serve writes track t of the video at videoPath as WebVTT. all lists the video's tracks: the first request for an embedded track extracts every embedded text track in one pass, since that costs one read of the file.
type Track ¶
type Track struct {
ID string `json:"id"` // "e<N>" for embedded stream N, "x<hash>" for a sidecar file
Label string `json:"label"` // in English, such as "English (SDH)"
// Note is the track's own title, where it says more than its language
// and flags, such as "Commentary", so apps can build a label in their
// own language.
Note string `json:"note,omitempty"`
Language string `json:"language,omitempty"` // ISO 639-1 where known, e.g. "en"
Codec string `json:"codec"`
Forced bool `json:"forced,omitempty"`
Default bool `json:"default,omitempty"`
SDH bool `json:"sdh,omitempty"`
External bool `json:"external,omitempty"`
// BurnIn marks picture-based subtitles (PGS, VobSub, DVB), which browsers
// can't render: the server draws them into the video during a transcode.
BurnIn bool `json:"burnIn,omitempty"`
Stream int `json:"-"` // embedded: index among the file's subtitle streams
Path string `json:"-"` // external: the sidecar file
}
Track is one subtitle track a player can offer.