encode

package
v0.0.0-...-ea53c28 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package encode provides the parallel chunk encoding pipeline.

Index

Constants

This section is empty.

Variables

View Source
var ErrMemoryPressure = errors.New("memory pressure critical; canceled before swap exhaustion")

ErrMemoryPressure is returned when Reel cancels encoding to avoid system OOM.

Functions

func EncodeAll

func EncodeAll(
	ctx context.Context,
	chunks []chunk.Chunk,
	inputPath string,
	inf *video.Info,
	cfg *EncodeConfig,
	workDir string,
	cropRect *video.CropRect,
	progressCb ProgressCallback,
) (int, error)

EncodeAll runs the parallel encoding pipeline. Uses streaming frame pipeline: each worker decodes and encodes one frame at a time, avoiding the need to hold all frames in memory at once.

Returns (maxWorkers, error) where maxWorkers is the adaptive concurrency ceiling.

func EncodeTargetQuality

func EncodeTargetQuality(
	ctx context.Context,
	chunks []chunk.Chunk,
	inputPath string,
	inf *video.Info,
	cfg *EncodeConfig,
	workDir string,
	cropRect *video.CropRect,
	progressCb ProgressCallback,
	tq TargetQualityConfig,
) (int, error)

func MaxAdaptiveWorkers

func MaxAdaptiveWorkers() int

MaxAdaptiveWorkers returns the hardware-derived adaptive concurrency ceiling.

Types

type EncodeConfig

type EncodeConfig struct {
	CRF                float32 // Quality (CRF value)
	Preset             uint8   // SVT-AV1 preset
	Tune               uint8   // SVT-AV1 tune
	GrainTable         *string // Optional film grain table path
	LevelOfParallelism uint32  // SVT-AV1 level_of_parallelism (1-6); 0 lets Reel choose
	// StatusCallback receives verbose-only limiter status (ramp-up messages).
	StatusCallback func(message string)
	// WarningCallback receives degraded-behavior limiter status (worker
	// reductions and the critical cancel) unconditionally, independent of
	// verbose mode, since these describe output-affecting decisions.
	WarningCallback func(message string)

	// Advanced SVT-AV1 parameters
	ACBias                float32
	EnableVarianceBoost   bool
	VarianceBoostStrength uint8
	VarianceOctile        uint8
}

EncodeConfig contains configuration for the parallel encode pipeline.

type ProgressCallback

type ProgressCallback func(progress worker.Progress)

ProgressCallback is called to report encoding progress.

type TargetQualityConfig

type TargetQualityConfig struct {
	// Metric selects the probe metric; Target/Tolerance are denominated in
	// its units (CVVDP JOD or SSIMU2 points). Empty means CVVDP.
	Metric        quality.MetricKind
	Target        float32
	Tolerance     float32
	CRFMin        float32
	CRFMax        float32
	MaxProbes     int
	MetricWorkers int
	DisplayPath   string
	InitialCRF    float32
	Verbose       func(string)
}

Jump to

Keyboard shortcuts

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