Documentation
¶
Overview ¶
Convenience wrapper around ffmpeg as a transcoder to DASH chunks https://github.com/go-cmd/cmd/blob/master/cmd.go was very useful while writing this module.
Index ¶
- Constants
- Variables
- func CleanTranscodingCache() error
- func ComputeSegmentDurations(sessions [][]Segment) []time.Duration
- func EncoderParamsToString(m EncoderParams) string
- func GetAVC1Tag(width int, height int, biteRate int64, frameRate *big.Rat) string
- func GetHumanizedToLangTag() map[string]string
- func GetLanguageTag(stream ProbeStream) string
- func GetTitleOrHumanizedLanguage(stream ProbeStream) string
- type ClientCodecCapabilities
- type DtsTimestamp
- type EncoderParams
- type Interval
- type ProbeContainer
- type ProbeData
- type ProbeFormat
- type ProbeStream
- type Representation
- type Segment
- type Stream
- type StreamKey
- type StreamRepresentation
- func GetSimilarTranscodedRepresentation(stream Stream) StreamRepresentation
- func GetStandardPresetVideoRepresentations(stream Stream) []StreamRepresentation
- func GetSubtitleStreamRepresentation(stream Stream) StreamRepresentation
- func GetSubtitleStreamRepresentations(streams []Stream) []StreamRepresentation
- func GetTranscodedAudioRepresentation(stream Stream, representationId string, encoderParams EncoderParams) StreamRepresentation
- func GetTranscodedVideoRepresentation(stream Stream, representationId string, encoderParams EncoderParams) StreamRepresentation
- func GetTransmuxedOrTranscodedRepresentation(stream Stream, capabilities ClientCodecCapabilities) (StreamRepresentation, error)
- func GetTransmuxedRepresentation(stream Stream) StreamRepresentation
- func StreamRepresentationFromRepresentationId(s Stream, representationId string) (StreamRepresentation, error)
- type Streams
- type TranscodingSession
- func NewAudioTranscodingSession(stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, ...) (*TranscodingSession, error)
- func NewSubtitleSession(stream StreamRepresentation, outputDirBase string) (*TranscodingSession, error)
- func NewTranscodingSession(s StreamRepresentation, segmentStartIndex int, feedbackURL string) (*TranscodingSession, error)
- func NewTransmuxingSession(stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, ...) (*TranscodingSession, error)
- func NewVideoTranscodingSession(stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, ...) (*TranscodingSession, error)
Constants ¶
const SegmentDuration = 5000 * time.Millisecond
MinSegDuration defines the duration of segments that ffmpeg will generate. In the transmuxing case this is really just a minimum time, the actual segments will be longer because they are cut at keyframes. For transcoding, we can force keyframes to occur exactly every MinSegDuration, so MinSegDuration will be the actualy duration of the segments.
const TotalDurationInvalid = float64(-1)
Variables ¶
var AudioEncoderPresets = map[string]EncoderParams{ "64k-audio": {Codecs: "mp4a.40.2", /* contains filtered or unexported fields */}, "128k-audio": {Codecs: "mp4a.40.2", /* contains filtered or unexported fields */}, }
var FfmpegUrlPort = 8080
TODO(Leon Handreke): Figure out a better way than a package-global variable to convey this info from the top-level command flag to ffmpeg. Or maybe a setter is enough? Also this should go in some util package to build URLs
var InitialSegmentIdx int = -1
Magic segment index value to denote the inital segment
Functions ¶
func CleanTranscodingCache ¶
func CleanTranscodingCache() error
func ComputeSegmentDurations ¶
func EncoderParamsToString ¶
func EncoderParamsToString(m EncoderParams) string
func GetHumanizedToLangTag ¶
func GetLanguageTag ¶
func GetLanguageTag(stream ProbeStream) string
func GetTitleOrHumanizedLanguage ¶
func GetTitleOrHumanizedLanguage(stream ProbeStream) string
Types ¶
type ClientCodecCapabilities ¶
type ClientCodecCapabilities struct {
PlayableCodecs []string `json:"playableCodecs"`
}
func (*ClientCodecCapabilities) CanPlay ¶
func (c *ClientCodecCapabilities) CanPlay(sr StreamRepresentation) bool
func (*ClientCodecCapabilities) Filter ¶
func (c *ClientCodecCapabilities) Filter( representations []StreamRepresentation) []StreamRepresentation
type EncoderParams ¶
type EncoderParams struct {
// The codecs (https://tools.ietf.org/html/rfc6381#section-3.3) that these params will produce.
Codecs string
// contains filtered or unexported fields
}
func EncoderParamsFromString ¶
func EncoderParamsFromString(str string) (EncoderParams, error)
func GetSimilarEncoderParams ¶
func GetSimilarEncoderParams(stream Stream) (EncoderParams, error)
func GetVideoEncoderPreset ¶
func GetVideoEncoderPreset(stream Stream, name string) (EncoderParams, error)
type Interval ¶
type Interval struct {
TimeBase int64
StartTimestamp DtsTimestamp
EndTimestamp DtsTimestamp
}
A time interval [StartTimestamp, EndTimestamp) in DTS
func (*Interval) EndDuration ¶
func (*Interval) StartDuration ¶
type ProbeContainer ¶
type ProbeContainer struct {
Streams []ProbeStream `json:"streams"`
Format ProbeFormat `json:"format"`
}
func Probe ¶
func Probe(fileLocator filesystem.FileLocator) (*ProbeContainer, error)
type ProbeData ¶
type ProbeData struct {
Format *ProbeFormat `json:"format,omitempty"`
}
type ProbeFormat ¶
type ProbeFormat struct {
Filename string `json:"filename"`
NBStreams int `json:"nb_streams"`
NBPrograms int `json:"nb_programs"`
FormatName string `json:"format_name"`
FormatLongName string `json:"format_long_name"`
StartTimeSeconds float64 `json:"start_time,string"`
DurationSeconds float64 `json:"duration,string"`
Size uint64 `json:"size,string"`
BitRate uint64 `json:"bit_rate,string"`
ProbeScore float64 `json:"probe_score"`
Tags map[string]string `json:"tags"`
}
func (ProbeFormat) StartTime ¶
func (f ProbeFormat) StartTime() time.Duration
type ProbeStream ¶
type ProbeStream struct {
Index int `json:"index"`
CodecName string `json:"codec_name"`
CodecLongName string `json:"codec_long_name"`
CodecTag string `json:"codec_tag"`
Profile string `json:"profile"`
Level int `json:"level"`
Channels int `json:"channels"`
ChannelLayout string `json:"channel_layout"`
CodecType string `json:"codec_type"`
BitRate string `json:"bit_rate"`
Width int `json:"width"`
Height int `json:"height"`
Extradata string `json:"extradata"`
Tags map[string]string `json:"tags"`
Disposition map[string]int `json:"disposition"`
TimeBase string `json:"time_base"`
DurationTs int `json:"duration_ts"`
RFrameRate string `json:"r_frame_rate"`
}
func FilterProbeStreamByCodecType ¶
func FilterProbeStreamByCodecType(streams []ProbeStream, codecType string) []ProbeStream
func (*ProbeStream) GetMime ¶
func (self *ProbeStream) GetMime() string
func (*ProbeStream) String ¶
func (ps *ProbeStream) String() string
type Representation ¶
type Representation struct {
RepresentationId string
// The rest is just metadata for display
BitRate int
Height int
Width int
// e.g. "video/mp4"
Container string
// codecs string ready for DASH/HLS serving
Codecs string
// Mutually exclusive
Transcoded bool
Transmuxed bool
// contains filtered or unexported fields
}
type Stream ¶
type Stream struct {
StreamKey
TotalDuration time.Duration
TimeBase *big.Rat
TotalDurationDts DtsTimestamp
// codecs string ready for DASH/HLS serving
Codecs string
CodecName string
Profile string
BitRate int64
FrameRate *big.Rat
Width int
Height int
// "audio", "video", "subtitle"
StreamType string
// Only relevant for audio and subtitles. Language code.
Language string
// User-visible string for this audio or subtitle track
Title string
EnabledByDefault bool
}
type StreamKey ¶
type StreamKey struct {
FileLocator filesystem.FileLocator
// StreamId from ffmpeg
// StreamId is always 0 for transmuxing
StreamId int64
}
type StreamRepresentation ¶
type StreamRepresentation struct {
Stream Stream
Representation Representation
}
func GetSimilarTranscodedRepresentation ¶
func GetSimilarTranscodedRepresentation(stream Stream) StreamRepresentation
func GetStandardPresetVideoRepresentations ¶
func GetStandardPresetVideoRepresentations(stream Stream) []StreamRepresentation
func GetSubtitleStreamRepresentation ¶
func GetSubtitleStreamRepresentation(stream Stream) StreamRepresentation
func GetSubtitleStreamRepresentations ¶
func GetSubtitleStreamRepresentations(streams []Stream) []StreamRepresentation
func GetTranscodedAudioRepresentation ¶
func GetTranscodedAudioRepresentation(stream Stream, representationId string, encoderParams EncoderParams) StreamRepresentation
func GetTranscodedVideoRepresentation ¶
func GetTranscodedVideoRepresentation( stream Stream, representationId string, encoderParams EncoderParams) StreamRepresentation
func GetTransmuxedOrTranscodedRepresentation ¶
func GetTransmuxedOrTranscodedRepresentation( stream Stream, capabilities ClientCodecCapabilities) (StreamRepresentation, error)
func GetTransmuxedRepresentation ¶
func GetTransmuxedRepresentation(stream Stream) StreamRepresentation
func StreamRepresentationFromRepresentationId ¶
func StreamRepresentationFromRepresentationId( s Stream, representationId string) (StreamRepresentation, error)
TODO(Leon Handreke): Should this really return an error?
type Streams ¶
func GetStreams ¶
func GetStreams(fileLocator filesystem.FileLocator) (*Streams, error)
func (*Streams) GetVideoStream ¶
type TranscodingSession ¶
type TranscodingSession struct {
Stream StreamRepresentation
OutputDir string
Terminated bool
Throttled bool
ProgressPercent float32
// contains filtered or unexported fields
}
Many attributes in this struct are only public because they are displayed on a the debug page.
func NewAudioTranscodingSession ¶
func NewAudioTranscodingSession( stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, outputDirBase string, feedbackURL string) (*TranscodingSession, error)
func NewSubtitleSession ¶
func NewSubtitleSession( stream StreamRepresentation, outputDirBase string) (*TranscodingSession, error)
func NewTranscodingSession ¶
func NewTranscodingSession(s StreamRepresentation, segmentStartIndex int, feedbackURL string) (*TranscodingSession, error)
func NewTransmuxingSession ¶
func NewTransmuxingSession( stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, outputDirBase string, feedbackURL string) (*TranscodingSession, error)
NewTransmuxingSession starts a new transmuxing-only (aka "Direct Stream") session.
func NewVideoTranscodingSession ¶
func NewVideoTranscodingSession( stream StreamRepresentation, startTime time.Duration, segmentStartIndex int, outputDirBase string, feedbackURL string) (*TranscodingSession, error)
func (*TranscodingSession) AvailableSegments ¶
func (s *TranscodingSession) AvailableSegments() (map[int]string, error)
func (*TranscodingSession) Destroy ¶
func (s *TranscodingSession) Destroy() error
func (*TranscodingSession) Start ¶
func (s *TranscodingSession) Start() error