transcode

package
v0.0.0-...-b56887b Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package transcode provides the ffmpeg transcoding functionality of the wavepipe media server.

Index

Constants

View Source
const (
	// FFmpegMP3Codec contains the ffmpeg codec used to transcode to MP3
	FFmpegMP3Codec = "libmp3lame"
	// FFmpegOGGCodec contains the ffmpeg codec used to transcode to Ogg Vorbis
	FFmpegOGGCodec = "libvorbis"
	// FFmpegOPUSCodec contains the ffmpeg codec used to transcode to Opus
	FFmpegOPUSCodec = "libopus"
)

Variables

View Source
var (
	// ErrInvalidCodec is returned when an invalid transcoder codec is selected
	ErrInvalidCodec = errors.New("transcode: no such transcoder codec")
	// ErrInvalidQuality is returned when an invalid quality is selected for a given codec
	ErrInvalidQuality = errors.New("transcode: invalid quality for transcoder codec")
	// ErrTranscodingDisabled is returned when the transcoding subsystem is disabled, due
	// to not being able to find ffmpeg
	ErrTranscodingDisabled = errors.New("transcode: could not find ffmpeg, transcoding is disabled")
	// ErrMP3Disabled is returned when MP3 transcoding is disabled, due to ffmpeg not
	// containing the necessary codec
	ErrMP3Disabled = errors.New("transcode: " + FFmpegMP3Codec + " codec not found, MP3 transcoding is disabled")
	// ErrOGGDisabled is returned when OGG transcoding is disabled, due to ffmpeg not
	// containing the necessary codec
	ErrOGGDisabled = errors.New("transcode: " + FFmpegOGGCodec + " codec not found, OGG transcoding is disabled")
	// ErrOPUSDisabled is returned when OPUS transcoding is disabled, due to ffmpeg not
	// containing the necessary codec
	ErrOPUSDisabled = errors.New("transcode: " + FFmpegOPUSCodec + " codec not found, OPUS transcoding is disabled")
)
View Source
var CodecSet = set.New()

CodecSet is the set of codecs which wavepipe detected for use with ffmpeg

View Source
var Enabled bool

Enabled determines whether transcoding is available and enabled for wavepipe

View Source
var (
	// ErrFFmpegNotStarted is returned when ffmpeg is not started before attempting to
	// retrieve its output stream, or wait for it to exit
	ErrFFmpegNotStarted = errors.New("ffmpeg: transcoding process has not started")
)
View Source
var FFmpegPath string

FFmpegPath is the path to the ffmpeg binary detected by the transcode manager

Functions

This section is empty.

Types

type FFmpeg

type FFmpeg struct {
	// contains filtered or unexported fields
}

FFmpeg represents the ffmpeg media encoder, and is used to provide a more flexible interface than chaining together command-line arguments

func NewFFmpeg

func NewFFmpeg(song *data.Song, options Options) *FFmpeg

NewFFmpeg creates a new FFmpeg instance using the input song and options

func (FFmpeg) Arguments

func (f FFmpeg) Arguments() []string

Arguments outputs a slice of the ffmpeg arguments needed to output audio on stdout

func (*FFmpeg) Start

func (f *FFmpeg) Start() error

Start invokes the ffmpeg media encoder using the path discovered by the transcode manager

func (FFmpeg) Stream

func (f FFmpeg) Stream() (io.ReadCloser, error)

Stream returns the current stream which ffmpeg is feeding while started

func (*FFmpeg) Wait

func (f *FFmpeg) Wait() error

Wait waits for the ffmpeg instance to exit

type MP3CBROptions

type MP3CBROptions struct {
	// contains filtered or unexported fields
}

MP3CBROptions represents the options for a MP3 CBR transcoder

func (MP3CBROptions) Codec

func (m MP3CBROptions) Codec() string

Codec returns the codec used

func (MP3CBROptions) Ext

func (m MP3CBROptions) Ext() string

Ext returns the file extension used

func (MP3CBROptions) FFmpegCodec

func (m MP3CBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (MP3CBROptions) FFmpegFlags

func (m MP3CBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (MP3CBROptions) FFmpegQuality

func (m MP3CBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (MP3CBROptions) MIMEType

func (m MP3CBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (MP3CBROptions) Quality

func (m MP3CBROptions) Quality() string

Quality returns the quality used

type MP3Transcoder

type MP3Transcoder struct {
	Options Options
	// contains filtered or unexported fields
}

MP3Transcoder represents a MP3 transcoding operation

func (MP3Transcoder) Codec

func (m MP3Transcoder) Codec() string

Codec returns the selected codec used by the transcoder

func (MP3Transcoder) Command

func (m MP3Transcoder) Command() []string

Command returns the command invoked by ffmpeg, for debugging

func (MP3Transcoder) MIMEType

func (m MP3Transcoder) MIMEType() string

MIMEType returns the MIME type contained within the options

func (MP3Transcoder) Quality

func (m MP3Transcoder) Quality() string

Quality returns the selected quality used by the transcoder

func (*MP3Transcoder) Start

func (m *MP3Transcoder) Start(song *data.Song) (io.ReadCloser, error)

Start begins the transcoding process, and returns a stream which contains its output

func (*MP3Transcoder) Wait

func (m *MP3Transcoder) Wait() error

Wait waits for the transcoding process to complete, returning an error if it fails

type MP3VBROptions

type MP3VBROptions struct {
	// contains filtered or unexported fields
}

MP3VBROptions represents the options for a MP3 VBR transcoder

func (MP3VBROptions) Codec

func (m MP3VBROptions) Codec() string

Codec returns the codec used

func (MP3VBROptions) Ext

func (m MP3VBROptions) Ext() string

Ext returns the file extension used

func (MP3VBROptions) FFmpegCodec

func (m MP3VBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (MP3VBROptions) FFmpegFlags

func (m MP3VBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (MP3VBROptions) FFmpegQuality

func (m MP3VBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (MP3VBROptions) MIMEType

func (m MP3VBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (MP3VBROptions) Quality

func (m MP3VBROptions) Quality() string

Quality returns the quality used

type OGGCBROptions

type OGGCBROptions struct {
	// contains filtered or unexported fields
}

OGGCBROptions represents the options for a OGG CBR transcoder

func (OGGCBROptions) Codec

func (m OGGCBROptions) Codec() string

Codec returns the codec used

func (OGGCBROptions) Ext

func (m OGGCBROptions) Ext() string

Ext returns the file extension used

func (OGGCBROptions) FFmpegCodec

func (m OGGCBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (OGGCBROptions) FFmpegFlags

func (m OGGCBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (OGGCBROptions) FFmpegQuality

func (m OGGCBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (OGGCBROptions) MIMEType

func (m OGGCBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (OGGCBROptions) Quality

func (m OGGCBROptions) Quality() string

Quality returns the quality used

type OGGTranscoder

type OGGTranscoder struct {
	Options Options
	// contains filtered or unexported fields
}

OGGTranscoder represents a OGG transcoding operation

func (OGGTranscoder) Codec

func (m OGGTranscoder) Codec() string

Codec returns the selected codec used by the transcoder

func (OGGTranscoder) Command

func (m OGGTranscoder) Command() []string

Command returns the command invoked by ffmpeg, for debugging

func (OGGTranscoder) MIMEType

func (m OGGTranscoder) MIMEType() string

MIMEType returns the MIME type contained within the options

func (OGGTranscoder) Quality

func (m OGGTranscoder) Quality() string

Quality returns the selected quality used by the transcoder

func (*OGGTranscoder) Start

func (m *OGGTranscoder) Start(song *data.Song) (io.ReadCloser, error)

Start begins the transcoding process, and returns a stream which contains its output

func (*OGGTranscoder) Wait

func (m *OGGTranscoder) Wait() error

Wait waits for the transcoding process to complete, returning an error if it fails

type OGGVBROptions

type OGGVBROptions struct {
	// contains filtered or unexported fields
}

OGGVBROptions represents the options for a OGG VBR transcoder

func (OGGVBROptions) Codec

func (m OGGVBROptions) Codec() string

Codec returns the codec used

func (OGGVBROptions) Ext

func (m OGGVBROptions) Ext() string

Ext returns the file extension used

func (OGGVBROptions) FFmpegCodec

func (m OGGVBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (OGGVBROptions) FFmpegFlags

func (m OGGVBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (OGGVBROptions) FFmpegQuality

func (m OGGVBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (OGGVBROptions) MIMEType

func (m OGGVBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (OGGVBROptions) Quality

func (m OGGVBROptions) Quality() string

Quality returns the quality used

type OPUSCBROptions

type OPUSCBROptions struct {
	// contains filtered or unexported fields
}

OPUSCBROptions represents the options for a OPUS CBR transcoder

func (OPUSCBROptions) Codec

func (m OPUSCBROptions) Codec() string

Codec returns the codec used

func (OPUSCBROptions) Ext

func (m OPUSCBROptions) Ext() string

Ext returns the file extension used

func (OPUSCBROptions) FFmpegCodec

func (m OPUSCBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (OPUSCBROptions) FFmpegFlags

func (m OPUSCBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (OPUSCBROptions) FFmpegQuality

func (m OPUSCBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (OPUSCBROptions) MIMEType

func (m OPUSCBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (OPUSCBROptions) Quality

func (m OPUSCBROptions) Quality() string

Quality returns the quality used

type OPUSTranscoder

type OPUSTranscoder struct {
	Options Options
	// contains filtered or unexported fields
}

OPUSTranscoder represents a OPUS transcoding operation

func (OPUSTranscoder) Codec

func (m OPUSTranscoder) Codec() string

Codec returns the selected codec used by the transcoder

func (OPUSTranscoder) Command

func (m OPUSTranscoder) Command() []string

Command returns the command invoked by ffmpeg, for debugging

func (OPUSTranscoder) MIMEType

func (m OPUSTranscoder) MIMEType() string

MIMEType returns the MIME type contained within the options

func (OPUSTranscoder) Quality

func (m OPUSTranscoder) Quality() string

Quality returns the selected quality used by the transcoder

func (*OPUSTranscoder) Start

func (m *OPUSTranscoder) Start(song *data.Song) (io.ReadCloser, error)

Start begins the transcoding process, and returns a stream which contains its output

func (*OPUSTranscoder) Wait

func (m *OPUSTranscoder) Wait() error

Wait waits for the transcoding process to complete, returning an error if it fails

type OPUSVBROptions

type OPUSVBROptions struct {
	// contains filtered or unexported fields
}

OPUSVBROptions represents the options for a OPUS VBR transcoder

func (OPUSVBROptions) Codec

func (m OPUSVBROptions) Codec() string

Codec returns the codec used

func (OPUSVBROptions) Ext

func (m OPUSVBROptions) Ext() string

Ext returns the file extension used

func (OPUSVBROptions) FFmpegCodec

func (m OPUSVBROptions) FFmpegCodec() string

FFmpegCodec returns the codec used by ffmpeg

func (OPUSVBROptions) FFmpegFlags

func (m OPUSVBROptions) FFmpegFlags() string

FFmpegFlags returns the flag used by ffmpeg to signify this encoding

func (OPUSVBROptions) FFmpegQuality

func (m OPUSVBROptions) FFmpegQuality() string

FFmpegQuality returns the quality flag used by ffmpeg

func (OPUSVBROptions) MIMEType

func (m OPUSVBROptions) MIMEType() string

MIMEType returns the MIME type of this item

func (OPUSVBROptions) Quality

func (m OPUSVBROptions) Quality() string

Quality returns the quality used

type Options

type Options interface {
	Codec() string
	Ext() string
	FFmpegCodec() string
	FFmpegFlags() string
	FFmpegQuality() string
	MIMEType() string
	Quality() string
}

Options represents an audio codec and its quality settings, and includes methods to retrieve these settings

type Transcoder

type Transcoder interface {
	Codec() string
	Command() []string
	MIMEType() string
	Start(*data.Song) (io.ReadCloser, error)
	Wait() error
	Quality() string
	// contains filtered or unexported methods
}

Transcoder represents a transcoding operation, and the methods which must be defined for a transcoder

func Factory

func Factory(codec string, quality string) (Transcoder, error)

Factory generates a new Transcoder depending on the input parameters

Jump to

Keyboard shortcuts

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