Documentation
¶
Overview ¶
Package reel provides a Go library for AV1 video encoding with SVT-AV1.
Package reel provides a Go library for AV1 video encoding with SVT-AV1.
Reel is an opinionated AV1 encoder that handles the complexity of video encoding with sensible defaults, automatic crop detection, HDR metadata preservation, and post-encode validation.
Basic usage:
encoder, err := reel.New(
reel.WithCRF(26),
)
if err != nil {
log.Fatal(err)
}
result, err := encoder.Encode(ctx, "input.mkv", "output/", nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Encoded: %s, reduction: %.1f%%\n",
result.OutputFile, result.SizeReductionPercent)
Index ¶
- Constants
- func FindVideos(dir string) ([]string, error)
- func NewTimestamp() int64
- type BaseEvent
- type BatchCompleteEvent
- type BatchResult
- type BatchStartInfo
- type BatchSummary
- type CropSummary
- type Encoder
- func (e *Encoder) Encode(ctx context.Context, input, outputDir string, handler EventHandler) (*Result, error)
- func (e *Encoder) EncodeBatch(ctx context.Context, inputs []string, outputDir string, handler EventHandler) (*BatchResult, error)
- func (e *Encoder) EncodeWithReporter(ctx context.Context, input, outputDir string, rep Reporter) (*Result, error)
- type EncodingCompleteEvent
- type EncodingConfigSummary
- type EncodingOutcome
- type EncodingProgressEvent
- type ErrorEvent
- type Event
- type EventHandler
- type FileProgressContext
- type FileResult
- type HardwareSummary
- type InitializationSummary
- type NullReporter
- type Option
- func WithCRF[T crfValue](crf T) Option
- func WithCRFByResolution[SD crfValue, HD crfValue, UHD crfValue](sd SD, hd HD, uhd UHD) Option
- func WithCVVDPDisplay(path string) Option
- func WithDisableAutocrop() Option
- func WithQualityMode(mode string) Option
- func WithTargetQuality(targetRange string) Option
- type ProgressSnapshot
- type Reporter
- type ReporterError
- type ReporterValidationStep
- type Result
- type StageProgress
- type ValidationCompleteEvent
- type ValidationStep
- type ValidationSummary
- type WarningEvent
Constants ¶
const ( EventTypeHardware = "hardware" EventTypeInitialization = "initialization" EventTypeStageProgress = "stage_progress" EventTypeEncodingStarted = "encoding_started" EventTypeEncodingConfig = "encoding_config" EventTypeCropResult = "crop_result" EventTypeEncodingProgress = "encoding_progress" EventTypeValidationComplete = "validation_complete" EventTypeEncodingComplete = "encoding_complete" EventTypeOperationComplete = "operation_complete" EventTypeBatchStarted = "batch_started" EventTypeFileProgress = "file_progress" EventTypeBatchComplete = "batch_complete" EventTypeWarning = "warning" EventTypeError = "error" )
Event types for Spindle integration.
Variables ¶
This section is empty.
Functions ¶
func FindVideos ¶
FindVideos finds video files in a directory.
Types ¶
type BatchCompleteEvent ¶
type BatchCompleteEvent struct {
BaseEvent
SuccessfulCount int `json:"successful_count"`
TotalFiles int `json:"total_files"`
TotalSizeReductionPercent float64 `json:"total_size_reduction_percent"`
}
BatchCompleteEvent represents batch completion.
type BatchResult ¶
type BatchResult struct {
Results []Result
SuccessfulCount int
TotalFiles int
TotalSizeReduction float64
ValidationPassedCount int
}
BatchResult contains the result of a batch encode.
type BatchStartInfo ¶
type BatchStartInfo = reporter.BatchStartInfo
BatchStartInfo contains batch start metadata.
type BatchSummary ¶
type BatchSummary = reporter.BatchSummary
BatchSummary contains batch completion information.
type CropSummary ¶
type CropSummary = reporter.CropSummary
CropSummary contains crop detection results.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is the main entry point for video encoding.
func (*Encoder) Encode ¶
func (e *Encoder) Encode(ctx context.Context, input, outputDir string, handler EventHandler) (*Result, error)
Encode encodes a single video file.
func (*Encoder) EncodeBatch ¶
func (e *Encoder) EncodeBatch(ctx context.Context, inputs []string, outputDir string, handler EventHandler) (*BatchResult, error)
EncodeBatch encodes multiple video files.
func (*Encoder) EncodeWithReporter ¶
func (e *Encoder) EncodeWithReporter(ctx context.Context, input, outputDir string, rep Reporter) (*Result, error)
EncodeWithReporter encodes a single video file using a custom Reporter. This provides direct access to all encoding events, unlike Encode which uses the EventHandler abstraction.
type EncodingCompleteEvent ¶
type EncodingCompleteEvent struct {
BaseEvent
OutputFile string `json:"output_file"`
OriginalSize uint64 `json:"original_size"`
EncodedSize uint64 `json:"encoded_size"`
SizeReductionPercent float64 `json:"size_reduction_percent"`
VideoOriginalSize uint64 `json:"video_original_size,omitempty"`
VideoEncodedSize uint64 `json:"video_encoded_size,omitempty"`
VideoSizeReductionPercent float64 `json:"video_size_reduction_percent,omitempty"`
}
EncodingCompleteEvent represents successful encode completion.
type EncodingConfigSummary ¶
type EncodingConfigSummary = reporter.EncodingConfigSummary
EncodingConfigSummary contains encoding configuration.
type EncodingOutcome ¶
type EncodingOutcome = reporter.EncodingOutcome
EncodingOutcome contains final encoding results.
type EncodingProgressEvent ¶
type EncodingProgressEvent struct {
BaseEvent
Percent float32 `json:"percent"`
Speed float32 `json:"speed"`
RecentSpeed float32 `json:"recent_speed"`
FPS float32 `json:"fps"`
ETASeconds int64 `json:"eta_seconds"`
}
EncodingProgressEvent represents encoding progress updates.
type ErrorEvent ¶
type ErrorEvent struct {
BaseEvent
Title string `json:"title"`
Message string `json:"message"`
Context string `json:"context"`
Suggestion string `json:"suggestion"`
}
ErrorEvent represents an error.
type EventHandler ¶
EventHandler is called with events during encoding.
type FileProgressContext ¶
type FileProgressContext = reporter.FileProgressContext
FileProgressContext contains current file index within a batch.
type FileResult ¶
type FileResult = reporter.FileResult
FileResult contains per-file encoding result.
type HardwareSummary ¶
type HardwareSummary = reporter.HardwareSummary
HardwareSummary contains hardware information.
type InitializationSummary ¶
type InitializationSummary = reporter.InitializationSummary
InitializationSummary describes the current file before encoding.
type NullReporter ¶
type NullReporter = reporter.NullReporter
NullReporter is a no-op reporter that discards all updates.
type Option ¶
Option configures the encoder.
func WithCRF ¶
func WithCRF[T crfValue](crf T) Option
WithCRF sets a single fixed CRF value for all resolutions (1-70 in 0.25 steps, lower is better quality).
func WithCRFByResolution ¶
func WithCRFByResolution[SD crfValue, HD crfValue, UHD crfValue](sd SD, hd HD, uhd UHD) Option
WithCRFByResolution sets resolution-specific fixed CRF values (1-70 in 0.25 steps, lower is better quality). SD applies to videos <1920 width, HD to >=1920 and <3840, UHD to >=3840.
func WithCVVDPDisplay ¶
WithCVVDPDisplay sets a VSHIP/CVVDP display JSON override for target-quality mode.
func WithDisableAutocrop ¶
func WithDisableAutocrop() Option
WithDisableAutocrop disables automatic black bar detection.
func WithQualityMode ¶
WithQualityMode selects target-quality (default) or fixed-CRF mode.
func WithTargetQuality ¶
WithTargetQuality sets the CVVDP JOD target range for target-quality mode.
type ProgressSnapshot ¶
type ProgressSnapshot = reporter.ProgressSnapshot
ProgressSnapshot contains encoding progress information.
type Reporter ¶
Reporter defines the interface for progress reporting during encoding. Implement this interface to receive detailed events about encoding progress.
type ReporterError ¶
type ReporterError = reporter.ReporterError
ReporterError contains error information.
type ReporterValidationStep ¶
type ReporterValidationStep = reporter.ValidationStep
ReporterValidationStep represents a single validation check from the reporter. Note: This is distinct from the ValidationStep type in events.go which is used for JSON serialization. Use reporter.ValidationStep internally.
type Result ¶
type Result struct {
OutputFile string
OriginalSize uint64
EncodedSize uint64
SizeReductionPercent float64
VideoOriginalSize uint64
VideoEncodedSize uint64
VideoSizeReductionPercent float64
ValidationPassed bool
EncodingSpeed float32
}
Result contains the result of a single file encode.
type StageProgress ¶
type StageProgress = reporter.StageProgress
StageProgress represents a generic stage update.
type ValidationCompleteEvent ¶
type ValidationCompleteEvent struct {
BaseEvent
ValidationPassed bool `json:"validation_passed"`
ValidationSteps []ValidationStep `json:"validation_steps"`
}
ValidationCompleteEvent represents validation completion.
type ValidationStep ¶
type ValidationStep struct {
Step string `json:"step"`
Passed bool `json:"passed"`
Details string `json:"details"`
}
ValidationStep represents a single validation check.
type ValidationSummary ¶
type ValidationSummary = reporter.ValidationSummary
ValidationSummary contains validation results.
type WarningEvent ¶
WarningEvent represents a warning message.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
reel
command
Package main provides the CLI entry point for Reel.
|
Package main provides the CLI entry point for Reel. |
|
internal
|
|
|
audio
Package audio provides native libav decoding and libopusenc audio encoding.
|
Package audio provides native libav decoding and libopusenc audio encoding. |
|
chunk
Package chunk provides types and functions for managing video encoding chunks.
|
Package chunk provides types and functions for managing video encoding chunks. |
|
chunkplan
Package chunkplan builds shot-aware chunk boundaries for video encoding.
|
Package chunkplan builds shot-aware chunk boundaries for video encoding. |
|
config
Package config provides configuration types and defaults for reel.
|
Package config provides configuration types and defaults for reel. |
|
discovery
Package discovery provides file discovery for video processing.
|
Package discovery provides file discovery for video processing. |
|
encode
Package encode provides the parallel chunk encoding pipeline.
|
Package encode provides the parallel chunk encoding pipeline. |
|
encoder
Package encoder provides SVT-AV1 library-based encoding for chunked encoding.
|
Package encoder provides SVT-AV1 library-based encoding for chunked encoding. |
|
keyframe
Package keyframe provides fixed-length chunk generation for video encoding.
|
Package keyframe provides fixed-length chunk generation for video encoding. |
|
logging
Package logging provides file logging for reel CLI.
|
Package logging provides file logging for reel CLI. |
|
media
Package media provides native libav media probing helpers.
|
Package media provides native libav media probing helpers. |
|
perf
Package perf collects per-file pipeline timing and adaptive-worker history and writes a perf.json artifact into the work directory.
|
Package perf collects per-file pipeline timing and adaptive-worker history and writes a perf.json artifact into the work directory. |
|
processing
Package processing provides video processing orchestration.
|
Package processing provides video processing orchestration. |
|
quality
Package quality contains target-quality search and CVVDP helpers.
|
Package quality contains target-quality search and CVVDP helpers. |
|
reporter
Package reporter provides progress reporting interfaces and implementations.
|
Package reporter provides progress reporting interfaces and implementations. |
|
util
Package util provides utility functions for formatting and common operations.
|
Package util provides utility functions for formatting and common operations. |
|
validation
Package validation provides post-encode validation checks.
|
Package validation provides post-encode validation checks. |
|
video
Package video provides FFmpeg/libav based video probing and frame extraction.
|
Package video provides FFmpeg/libav based video probing and frame extraction. |
|
worker
Package worker provides types and utilities for parallel chunk encoding.
|
Package worker provides types and utilities for parallel chunk encoding. |
|
scripts
|
|
|
aligncheck
command
aligncheck reproduces and locates the scoring frame-misalignment bug.
|
aligncheck reproduces and locates the scoring frame-misalignment bug. |
|
chunkbench
command
chunkbench runs shot detection and chunk planning without encoding.
|
chunkbench runs shot detection and chunk planning without encoding. |
|
fullvalidate
command
fullvalidate scores a finished Reel encode against its source with full-chunk CVVDP, giving ground-truth per-chunk JOD instead of the recorded scores the target-quality search reports about itself.
|
fullvalidate scores a finished Reel encode against its source with full-chunk CVVDP, giving ground-truth per-chunk JOD instead of the recorded scores the target-quality search reports about itself. |
|
handlertest
command
handlertest -- standing concurrency-safety check for VSHIP CVVDP scoring.
|
handlertest -- standing concurrency-safety check for VSHIP CVVDP scoring. |