encoder

package
v0.0.0-...-aa6cde0 Latest Latest
Warning

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

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

Documentation

Overview

Package encoder provides SVT-AV1 library-based encoding for chunked encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeChunkToIVF

func EncodeChunkToIVF(ctx context.Context, cfg *EncConfig, readFrame func([]byte) error, progressCb func(encoded int)) (err error)

EncodeChunkToIVF encodes a chunk of video frames to an IVF file using the SVT-AV1 library. readFrame is called for each frame to fill the provided buffer with 10-bit YUV420 data. progressCb is called periodically with the number of frames encoded so far.

func MaxBitRateBps

func MaxBitRateBps() uint32

MaxBitRateBps returns the bitstream cap applied to every encode, for the target-quality search to reject probes whose encodes escaped it.

func PeakSecondBps

func PeakSecondBps(r io.Reader, fpsNum, fpsDen uint32) (float64, error)

PeakSecondBps returns the highest one-second bitrate in an IVF file, bucketing frame payloads by displayed second (frame pts is the frame index in EncodeChunkToIVF's output). Hardware decoders are provisioned for the signaled level's instantaneous rate, so the target-quality search gates probes on this rather than on the chunk average.

func SVTVersion

func SVTVersion() string

SVTVersion returns the version string reported by the linked SVT-AV1 library.

func SvtParamsDisplay

func SvtParamsDisplay(acBias float32, enableVarianceBoost bool, tune uint8) string

SvtParamsDisplay returns a human-readable colon-separated string of key SVT-AV1 parameters for display purposes (similar to FFmpeg's -svtav1-params format).

Types

type EncConfig

type EncConfig struct {
	Inf                *video.Info // Video properties
	CRF                float32     // Quality (CRF value)
	Preset             uint8       // SVT-AV1 preset (0-13)
	Tune               uint8       // SVT-AV1 tune
	Output             string      // Output IVF path
	GrainTable         *string     // Optional film grain table path (not supported with library)
	Width              uint32      // Frame width (after cropping)
	Height             uint32      // Frame height (after cropping)
	Frames             int         // Number of frames to encode
	LevelOfParallelism uint32      // SVT-AV1 level_of_parallelism (1-6); 0 lets SVT choose

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

EncConfig contains configuration for encoding a chunk.

Jump to

Keyboard shortcuts

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