Documentation
¶
Index ¶
- type Streamer
- func (streamer *Streamer) Close()
- func (streamer *Streamer) Err() error
- func (streamer *Streamer) Read(data []byte) (n int, err error)
- func (streamer *Streamer) ReadSample() (float64, error)
- func (streamer *Streamer) SetVolume(volume float64) error
- func (streamer *Streamer) Write(data []byte) error
- func (streamer *Streamer) WriteSample(sample float64) error
- type Transmuxer
- 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(p []byte) (n int, err error)
- func (transmuxer *Transmuxer) Run()
- func (transmuxer *Transmuxer) SetMasterVolume(volume float64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Streamer ¶
type Streamer struct { Process *exec.Cmd Error error Volume float64 Stderr io.ReadCloser Stdin io.WriteCloser Stdout io.ReadCloser // contains filtered or unexported fields }
Streamer contains all the data required to run a streaming session.
func NewStreamer ¶
NewStreamer returns an initialized *Streamer or an error if one could not be created.
If filepath is empty, the ffmpeg process will not start. You can specify any ffmpeg-supported location, such as a network URL or a local filepath.
If args is nil or empty, the default values will be used. Do not specify your own args unless you understand how ffgoconv functions.
The variable volume must be a floating-point number between 0 and 1, representing a percentage value. For example, 20% volume would be 0.2.
func (*Streamer) Close ¶
func (streamer *Streamer) Close()
Close closes the streaming session and renders the streamer unusable.
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 Error error MasterVolume float64 Stderr io.ReadCloser Stdin io.WriteCloser Stdout io.ReadCloser // 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) 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()
Close closes the transmuxing session and renders the transmuxer unusable.
func (*Transmuxer) Err ¶
func (transmuxer *Transmuxer) Err() error
Err returns the latest transmuxing error.
func (*Transmuxer) IsRunning ¶
func (transmuxer *Transmuxer) IsRunning() bool
IsRunning returns whether or not the transmuxing session is running.
func (*Transmuxer) Read ¶
func (transmuxer *Transmuxer) Read(p []byte) (n int, err error)
Read implements io.Reader using the internal buffer.
func (*Transmuxer) SetMasterVolume ¶
func (transmuxer *Transmuxer) SetMasterVolume(volume float64) error
SetMasterVolume sets the master volume of the finalized audio.