Documentation
¶
Overview ¶
Package ffexec runs FFmpeg command-line tools and streams their output.
Index ¶
- Constants
- Variables
- func LineReader(fn func(line []byte) error) func(io.Reader) error
- func Lines(ctx context.Context, bin string, args []string, fn func(line []byte) error) error
- func Output(ctx context.Context, bin string, args []string) ([]byte, error)
- func Stream(ctx context.Context, bin string, args []string, consume func(io.Reader) error) error
- func StreamPair(ctx context.Context, bin string, args []string, ...) error
Constants ¶
const ExtraOutput = "pipe:3"
ExtraOutput is the file descriptor of the extra output of StreamPair in the child process: ffmpeg writes to it as "pipe:3".
Variables ¶
var ErrNotFound = errors.New("ffexec: binary not found")
ErrNotFound is returned when the requested binary is not in PATH.
Functions ¶
func LineReader ¶
LineReader is the consumer of Stream calling fn for every line, as Lines does.
func Lines ¶
Lines runs bin with args and calls fn for every stdout line. The line slice is only valid during the call. Returning an error from fn stops the process.
func Stream ¶
Stream runs bin with args and hands its stdout to consume. When consume returns an error the process is killed and that error is returned. A cancelled ctx kills the process and returns an error wrapping ctx.Err(); a non-zero exit returns an error carrying the beginning of stderr.
func StreamPair ¶
func StreamPair( ctx context.Context, bin string, args []string, consume func(stdout, extra io.Reader) error, ) error
StreamPair runs bin with args like Stream, with a second output: a pipe the process sees as file descriptor 3 (ExtraOutput). consume receives stdout and that pipe. A process writing both outputs as it goes (ffmpeg with two outputs) blocks on whichever pipe is full: consume must read both as the process writes them, typically in turn.
Types ¶
This section is empty.