Documentation
¶
Index ¶
- Variables
- func CheckVersion(ctx context.Context, ffmpegPath string)
- func Resolve(ctx context.Context) (string, error)
- func RunGraceful(ctx context.Context, ffmpegPath string, args []string, timeout time.Duration) error
- func RunOutput(ctx context.Context, ffmpegPath string, args []string) (string, error)
- type Executor
- type ExecutorOption
- type Resolver
- type ResolverOption
- func WithEnvProvider(e envProvider) ResolverOption
- func WithFileReader(r fileReader) ResolverOption
- func WithFileWriter(w fileWriter) ResolverOption
- func WithHTTPClient(c httpDoer) ResolverOption
- func WithPlatform(goos, goarch string) ResolverOption
- func WithPlatformInfo(info binaryInfo) ResolverOption
- func WithStderr(w io.Writer) ResolverOption
- type VersionChecker
- type VersionCheckerOption
Constants ¶
This section is empty.
Variables ¶
var ErrChecksumMismatch = errors.New("checksum mismatch")
ErrChecksumMismatch indicates a downloaded file's checksum verification failed.
var ErrDownloadFailed = errors.New("download failed")
ErrDownloadFailed indicates a file download could not be completed.
var ErrNotFound = errors.New("ffmpeg not found")
ErrNotFound indicates FFmpeg binary is not installed and auto-download failed.
var ErrTimeout = errors.New("ffmpeg did not exit within timeout")
ErrTimeout is returned when FFmpeg does not exit within the graceful shutdown timeout.
var ErrUnsupportedPlatform = errors.New("unsupported platform for FFmpeg auto-download")
ErrUnsupportedPlatform indicates the OS/architecture is not supported for auto-download.
Functions ¶
func CheckVersion ¶
CheckVersion verifies that ffmpeg meets minimum version requirements. This is a backward-compatible facade for the VersionChecker.Check method.
func Resolve ¶
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.
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.
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.
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.