ffmpeg

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChecksumMismatch = errors.New("checksum mismatch")

ErrChecksumMismatch indicates a downloaded file's checksum verification failed.

View Source
var ErrDownloadFailed = errors.New("download failed")

ErrDownloadFailed indicates a file download could not be completed.

View Source
var ErrNotFound = errors.New("ffmpeg not found")

ErrNotFound indicates FFmpeg binary is not installed and auto-download failed.

View Source
var ErrTimeout = errors.New("ffmpeg did not exit within timeout")

ErrTimeout is returned when FFmpeg does not exit within the graceful shutdown timeout.

View Source
var ErrUnsupportedPlatform = errors.New("unsupported platform for FFmpeg auto-download")

ErrUnsupportedPlatform indicates the OS/architecture is not supported for auto-download.

Functions

func CheckVersion

func CheckVersion(ctx context.Context, ffmpegPath string)

CheckVersion verifies that ffmpeg meets minimum version requirements. This is a backward-compatible facade for the VersionChecker.Check method.

func Resolve

func Resolve(ctx context.Context) (string, error)

Resolve finds ffmpeg using the default resolver. This is a backward-compatible facade for the Resolver.Resolve method.

func RunGraceful

func RunGraceful(ctx context.Context, ffmpegPath string, args []string, timeout time.Duration) error

RunGraceful executes FFmpeg with graceful shutdown on context cancellation. When ctx is canceled, it sends 'q' to stdin to allow FFmpeg to finalize the file properly (write headers, close container), then waits up to timeout before killing. This approach works cross-platform (Windows/macOS/Linux) unlike SIGTERM.

func RunOutput

func RunOutput(ctx context.Context, ffmpegPath string, args []string) (string, error)

RunOutput executes FFmpeg and captures its stderr output. This is a backward-compatible facade for the Executor.RunOutput method.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs FFmpeg commands with injectable dependencies.

func NewExecutor

func NewExecutor(opts ...ExecutorOption) *Executor

NewExecutor creates an Executor with the given options.

func (*Executor) RunOutput

func (e *Executor) RunOutput(ctx context.Context, ffmpegPath string, args []string) (string, error)

RunOutput executes FFmpeg and captures its stderr output. FFmpeg writes most diagnostic output (including device lists, probe info) to stderr.

type ExecutorOption

type ExecutorOption func(*Executor)

ExecutorOption configures an Executor.

func WithRunOutput

func WithRunOutput(fn runOutputFn) ExecutorOption

WithRunOutput sets a custom runOutput function (for testing).

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver finds and optionally downloads FFmpeg.

func NewResolver

func NewResolver(opts ...ResolverOption) *Resolver

NewResolver creates a Resolver with the given options. Uses production defaults if no options are provided.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context) (string, error)

Resolve finds ffmpeg using the following precedence:

  1. FFMPEG_PATH environment variable (error if set but invalid)
  2. ~/.go-transcript/bin/ffmpeg (installed by us)
  3. System PATH
  4. Auto-download if nothing found

type ResolverOption

type ResolverOption func(*Resolver)

ResolverOption configures a Resolver.

func WithEnvProvider

func WithEnvProvider(e envProvider) ResolverOption

WithEnvProvider sets the environment provider implementation.

func WithFileReader

func WithFileReader(r fileReader) ResolverOption

WithFileReader sets the file reader implementation.

func WithFileWriter

func WithFileWriter(w fileWriter) ResolverOption

WithFileWriter sets the file writer implementation.

func WithHTTPClient

func WithHTTPClient(c httpDoer) ResolverOption

WithHTTPClient sets the HTTP client implementation.

func WithPlatform

func WithPlatform(goos, goarch string) ResolverOption

WithPlatform sets the target platform (for testing cross-platform behavior).

func WithPlatformInfo

func WithPlatformInfo(info binaryInfo) ResolverOption

WithPlatformInfo overrides the platform download info (for testing downloads).

func WithStderr

func WithStderr(w io.Writer) ResolverOption

WithStderr sets the writer for status messages.

type VersionChecker

type VersionChecker struct {
	// contains filtered or unexported fields
}

VersionChecker verifies FFmpeg version requirements.

func NewVersionChecker

func NewVersionChecker(opts ...VersionCheckerOption) *VersionChecker

NewVersionChecker creates a VersionChecker with the given options.

func (*VersionChecker) Check

func (vc *VersionChecker) Check(ctx context.Context, ffmpegPath string) bool

Check verifies that ffmpeg meets minimum version requirements. Prints a warning to stderr if version is below minimum but doesn't fail. Returns true if version was successfully checked, false if parsing failed.

type VersionCheckerOption

type VersionCheckerOption func(*VersionChecker)

VersionCheckerOption configures a VersionChecker.

func WithVersionExecutor

func WithVersionExecutor(e *Executor) VersionCheckerOption

WithVersionExecutor sets the executor for running FFmpeg.

func WithVersionStderr

func WithVersionStderr(w io.Writer) VersionCheckerOption

WithVersionStderr sets the writer for warning messages.

Jump to

Keyboard shortcuts

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