ffgoconv

package module
v0.0.0-...-bb58fb0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 8 Imported by: 1

README

ffgoconv

A real-time transmuxer with full control of individual streamers and the final muxing process.

Note

This library is heavily a work-in-progress and is deemed alpha. Although it works as-is, function signatures and functionality may change without notice.

Installing

go get github.com/JoshuaDoes/ffgoconv

Documentation

Auto-generated documentation can be found below.

GoDoc

Example

An example can be found in the example directory. It provides a bare-minimum implementation of ffgoconv and takes ffmpeg stream locations as parameters, outputting a few seconds of audio to example/test.mp3.

License

The source code for ffgoconv is released under the MIT License. See LICENSE for more details.

Donations

All donations are appreciated and helps me focus on these projects more. Even if it's not much, it helps a lot in the long run!

Donate

Documentation

Index

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

func NewStreamer(filepath string, args []string, volume float64) (*Streamer, error)

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) Err

func (streamer *Streamer) Err() error

Err returns the latest streaming error.

func (*Streamer) Read

func (streamer *Streamer) Read(data []byte) (n int, err error)

Read implements an io.Reader wrapper around *Streamer.Stdout.

func (*Streamer) ReadSample

func (streamer *Streamer) ReadSample() (float64, error)

ReadSample returns the next audio sample from the streaming session.

func (*Streamer) SetVolume

func (streamer *Streamer) SetVolume(volume float64) error

SetVolume sets the volume of the finalized audio.

func (*Streamer) Write

func (streamer *Streamer) Write(data []byte) error

Write implements an io.Writer wrapper around *Streamer.Stdin.

func (*Streamer) WriteSample

func (streamer *Streamer) WriteSample(sample float64) error

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) Run

func (transmuxer *Transmuxer) Run()

Run starts the transmuxing session.

func (*Transmuxer) SetMasterVolume

func (transmuxer *Transmuxer) SetMasterVolume(volume float64) error

SetMasterVolume sets the master volume of the finalized audio.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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