ffexec

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ffexec runs FFmpeg command-line tools and streams their output.

Index

Constants

View Source
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

View Source
var ErrNotFound = errors.New("ffexec: binary not found")

ErrNotFound is returned when the requested binary is not in PATH.

Functions

func LineReader

func LineReader(
	fn func(line []byte) error,
) func(io.Reader) error

LineReader is the consumer of Stream calling fn for every line, as Lines does.

func Lines

func Lines(
	ctx context.Context,
	bin string,
	args []string,
	fn func(line []byte) error,
) error

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 Output

func Output(
	ctx context.Context,
	bin string,
	args []string,
) ([]byte, error)

Output runs bin with args and returns its whole stdout.

func Stream

func Stream(
	ctx context.Context,
	bin string,
	args []string,
	consume func(io.Reader) error,
) error

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.

Jump to

Keyboard shortcuts

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