Documentation ¶
Index ¶
- Variables
- type FFmpeg
- type Streamer
- type Transmuxer
- func (transmuxer *Transmuxer) AddRunningStreamer(streamer *Streamer) (*Streamer, error)
- func (transmuxer *Transmuxer) AddStreamer(filepath string, args []string, volume float64) (*Streamer, error)
- func (transmuxer *Transmuxer) Close()
- func (transmuxer *Transmuxer) Err() error
- func (transmuxer *Transmuxer) IsRunning() bool
- func (transmuxer *Transmuxer) Read(data []byte) (n int, err error)
- func (transmuxer *Transmuxer) Run()
- func (transmuxer *Transmuxer) SetMasterVolume(volume float64)
Constants ¶
This section is empty.
Variables ¶
var ( ErrFFmpegNotRunning = errors.New("ffgoconv: FFmpeg: not running") ErrFFmpegFilepathEmpty = errors.New("ffgoconv: filepath must not be empty") )
Functions ¶
This section is empty.
Types ¶
type FFmpeg ¶
type FFmpeg struct {
// contains filtered or unexported fields
}
FFmpeg contains all the data required to keep an FFmpeg process running and usable.
func NewFFmpeg ¶
NewFFmpeg returns an initialized *FFmpeg or an error if one could not be created.
If filepath is empty, the FFmpeg process will not start. You can specify any location supported by FFmpeg, such as a network location or a local filepath.
If args is nil or empty, the default values will be used. Do not specify your own arguments unless you understand how ffgoconv functions.
func (*FFmpeg) Close ¶
func (ff *FFmpeg) Close()
Close closes the FFmpeg process gracefully and renders the struct unusable.
func (*FFmpeg) Err ¶
Err returns the last stored error. Error histories are not kept, so check as soon as something goes wrong.
func (*FFmpeg) IsRunning ¶
IsRunning returns whether or not the FFmpeg process is running, per the knowledge of ffgoconv.
type Streamer ¶
Streamer contains all the data required to run a streaming session.
func NewStreamer ¶
func (*Streamer) Err ¶
Err returns the last stored error. Error histories are not kept, so check as soon as something goes wrong.
func (*Streamer) ReadSample ¶
ReadSample returns the next audio sample from the streaming session.
func (*Streamer) WriteSample ¶
WriteSample writes a new audio sample to the streaming session.
type Transmuxer ¶
type Transmuxer struct { sync.Mutex Streamers []*Streamer FinalStream *Streamer MasterVolume float64 // contains filtered or unexported fields }
Transmuxer contains all the data required to run a transmuxing session.
func NewTransmuxer ¶
func NewTransmuxer(streamers []*Streamer, outputFilepath, codec, format, bitrate string, masterVolume float64) (*Transmuxer, error)
NewTransmuxer returns an initialized *Transmuxer or an error if one could not be created.
If streamers is nil, it will be initialized automatically with an empty slice of *Streamer.
If codec is not specified, the ffmpeg process will not start. A list of possible codecs can be found with "ffmpeg -codecs".
If format is not specified, the ffmpeg process will not start. A list of possible formats can be found with "ffmpeg -formats".
If bitrate is not specified, the ffmpeg process will not start.
The variable masterVolume must be a floating-point number between 0 and 1, representing a percentage value. For example, 20% volume would be 0.2.
If outputFilepath is empty, a buffer of float64 PCM values will be initialized and the returned *Transmuxer can be then used as an io.Reader.
If outputFilepath is "pipe:1", the FinalStream *Streamer can be used as an io.Reader to receive encoded audio data of the chosen codec in the chosen format.
func (*Transmuxer) AddRunningStreamer ¶
func (transmuxer *Transmuxer) AddRunningStreamer(streamer *Streamer) (*Streamer, error)
AddRunningStreamer adds a pre-initialized *Streamer to the transmuxing session
func (*Transmuxer) AddStreamer ¶
func (transmuxer *Transmuxer) AddStreamer(filepath string, args []string, volume float64) (*Streamer, error)
AddStreamer initializes and adds a *Streamer to the transmuxing session, or returns an error if one could not be initialized. See NewStreamer for info on supported arguments.
func (*Transmuxer) Close ¶
func (transmuxer *Transmuxer) Close()
func (*Transmuxer) Err ¶
func (transmuxer *Transmuxer) Err() error
Err returns the last stored error. Error histories are not kept, so check as soon as something goes wrong.
func (*Transmuxer) IsRunning ¶
func (transmuxer *Transmuxer) IsRunning() bool
func (*Transmuxer) Read ¶
func (transmuxer *Transmuxer) Read(data []byte) (n int, err error)
Read implements an io.Reader wrapper around *Transmuxer.FinalStream.FFmpeg.stdout.
func (*Transmuxer) Run ¶
func (transmuxer *Transmuxer) Run()
func (*Transmuxer) SetMasterVolume ¶
func (transmuxer *Transmuxer) SetMasterVolume(volume float64)