analyze

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package analyze slowly works through the libraries in the background, recording each file's full media info: resolution and HDR, codecs and bitrates, audio channels and languages, subtitles. It is built to go unnoticed: one file at a time at the lowest CPU and disk priority, with a pause between files and while anyone is watching something transcoded, so network shares and the server stay responsive. Progress lives in the database, so it picks up where it was after a restart, and a file is looked at again only when it changes.

Index

Constants

View Source
const (
	StateAnalyzing = "analyzing"
	StateWaiting   = "waiting"  // for playback to finish
	StateSlowDisk  = "slowDisk" // files kept timing out; resting before trying again
	StateIdle      = "idle"     // everything is analyzed
	StateOff       = "off"
)

State says what the analysis is doing right now.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer struct {
	Store  *store.Store
	Prober probe.Prober // should be LowPriority
	Log    *slog.Logger
	// Busy reports whether anyone is watching something the server is
	// transcoding right now. Gentle analysis waits until nobody is.
	Busy func() bool
	// contains filtered or unexported fields
}

func (*Analyzer) Mode

func (a *Analyzer) Mode(ctx context.Context) (Mode, error)

Mode returns the admin's setting, Gentle unless they changed it.

func (*Analyzer) Reanalyze

func (a *Analyzer) Reanalyze(ctx context.Context, id int64) error

Reanalyze has one file looked at again soon, whatever its state.

func (*Analyzer) Run

func (a *Analyzer) Run(ctx context.Context)

Run analyzes files until ctx ends.

func (*Analyzer) SetMode

func (a *Analyzer) SetMode(ctx context.Context, m Mode) error

func (*Analyzer) Status

func (a *Analyzer) Status(ctx context.Context) (Status, error)

func (*Analyzer) Wake

func (a *Analyzer) Wake()

Wake has the analysis look for new or changed files now, after a scan or a setting change, instead of at its next regular pass.

type Mode

type Mode string

Mode is how hard the analysis works, an admin setting.

const (
	// Gentle analyzes a file every few seconds and waits while anyone is
	// watching something transcoded. The default.
	Gentle Mode = "gentle"
	// Normal analyzes files back to back, still at the lowest priority.
	Normal Mode = "normal"
	// Off pauses the analysis until it's turned back on.
	Off Mode = "off"
)

type Status

type Status struct {
	Mode  Mode   `json:"mode"`
	State string `json:"state"`
	// Total is how many files the libraries have; Done how many are analyzed
	// as they are now, Unreadable among them the ones ffprobe couldn't read.
	Total      int    `json:"total"`
	Done       int    `json:"done"`
	Unreadable int    `json:"unreadable"`
	Current    string `json:"current,omitempty"`
}

Status is the analysis' progress, for admins.

Jump to

Keyboard shortcuts

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