Documentation
¶
Overview ¶
Package analyze fans decoded frames out to independent analyzers.
Index ¶
- Variables
- func Run(ctx context.Context, src decode.Source, req decode.Request, ...) error
- func RunSegments(ctx context.Context, src decode.Source, reqs []decode.Request, workers int, ...) error
- func Splittable(analyzers []Analyzer) bool
- func Thumbnail(f *frame.Frame) []byte
- type Analyzer
- type Forker
- type Series
Constants ¶
This section is empty.
Variables ¶
var ErrSegment = errors.New("segment does not match the plan")
ErrSegment is returned by RunSegments when a segment did not yield the frames planned: fewer than requested, or not the frame the previous segment ended with (a seek that did not land where expected). The segments are then unusable; a single sequential pass still is.
Functions ¶
func Run ¶
func Run( ctx context.Context, src decode.Source, req decode.Request, analyzers []Analyzer, progress func(frames int), ) error
Run decodes req once and feeds every frame to all analyzers concurrently. progress, when not nil, receives the number of frames decoded so far.
The first error (decoder or analyzer) cancels the run; every analyzer is still closed, after its queue has been drained.
func RunSegments ¶
func RunSegments( ctx context.Context, src decode.Source, reqs []decode.Request, workers int, analyzers []Analyzer, progress func(frames int), ) error
RunSegments analyses a video decoded in segments, up to workers of them at once, each fed to forks of every analyzer (all must be Forkers, see Splittable). reqs are consecutive runs of frames in order, overlapping by one frame (see Forker); every request but the last must set MaxFrames. progress, when not nil, receives the number of distinct frames analysed so far; calls are serialised.
The first error (decoder, analyzer, ErrSegment) cancels the run; every fork and analyzer is still closed.
func Splittable ¶
Splittable reports whether every analyzer is a Forker: only then can a video be analysed in concurrent segments (RunSegments).
func Thumbnail ¶
Thumbnail returns the samples analyzers working at low resolution should read: the frame's thumbnail, or its full luma when the pool builds no thumbnails (pooled 8-bit planes have no row padding, so Pix is the image). Without this fallback an empty thumbnail would read as a black, frozen and cut-free picture.
Types ¶
type Analyzer ¶
Analyzer consumes decoded frames. Consume is called from a single goroutine in presentation order; an analyzer that keeps a frame after Consume returns must Retain it. Close is called once after the last frame.
type Forker ¶
Forker is implemented by analyzers whose work can be split into runs of consecutive frames analysed concurrently (RunSegments). Fork returns the analyzer of one run: it receives the frames of the run in order, from a single goroutine, while other forks analyse other runs, and it is closed after the last frame of its run. The Forker itself then receives no frame; it is closed after every fork, and its results must be those of a single sequential pass.
Consecutive runs overlap by one frame: the last frame of a run is the first frame of the next one. A fork measures what compares a frame with its predecessor (motion, cuts) from the second frame of its run on, as a sequential pass does from the second frame of the video, so every such measure is taken once, by the run holding both frames. Measures of the shared frame alone are taken by both runs, identically. Series merges per-frame values that way.
type Series ¶
type Series[T any] struct { // contains filtered or unexported fields }
Series gathers the per-frame values of an analyzer measured by runs of consecutive frames (its forks, or the single run of a sequential pass) and merges them in frame order. The zero value is ready to use and safe for concurrent use.
func (*Series[T]) Add ¶
Add records the values of the frames of a run, the first of them being frame first.
func (*Series[T]) Merge ¶
func (s *Series[T]) Merge() []T
Merge returns the values of every frame in order, the first value being that of the earliest frame measured. Where runs overlap, the earlier run's values are kept: that run also had the frame's predecessor (see Forker). Runs are expected to leave no gap (RunSegments checks it).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package analyzetest checks that analyzers split into concurrent runs (analyze.Forker) give the results of a sequential pass.
|
Package analyzetest checks that analyzers split into concurrent runs (analyze.Forker) give the results of a sequential pass. |
|
Package black detects black segments: runs of frames where nearly every thumbnail pixel is close to the nominal black level.
|
Package black detects black segments: runs of frames where nearly every thumbnail pixel is close to the nominal black level. |
|
Package crop detects letterboxing and pillarboxing: the smallest rectangle that contains the picture content across the whole video.
|
Package crop detects letterboxing and pillarboxing: the smallest rectangle that contains the picture content across the whole video. |
|
Package freeze detects frozen segments: runs of frames whose thumbnail does not change.
|
Package freeze detects frozen segments: runs of frames whose thumbnail does not change. |
|
Package grain estimates the grain of video from its 8-bit luma: the standard deviation of the noise and its lag-1 correlation, measured on the flattest blocks of each frame, where the high-pass residual is grain and not texture.
|
Package grain estimates the grain of video from its 8-bit luma: the standard deviation of the noise and its lag-1 correlation, measured on the flattest blocks of each frame, where the high-pass residual is grain and not texture. |
|
Package levels measures per-frame luma statistics on the full-resolution plane: average, extremes and share of samples outside the legal range.
|
Package levels measures per-frame luma statistics on the full-resolution plane: average, extremes and share of samples outside the legal range. |
|
Package light measures the light levels of HDR (PQ or HLG) frames: per frame, the brightest and the average display light of max(R, G, B) in cd/m², the quantities behind CTA-861.3's MaxCLL and MaxFALL.
|
Package light measures the light levels of HDR (PQ or HLG) frames: per frame, the brightest and the average display light of max(R, G, B) in cd/m², the quantities behind CTA-861.3's MaxCLL and MaxFALL. |
|
Package motion estimates the camera motion of every frame from the shared thumbnails, and classifies the camera work of every shot: static, pan, tilt, zoom, tracking (translation with parallax), handheld (shake) or mixed, with a shake measure.
|
Package motion estimates the camera motion of every frame from the shared thumbnails, and classifies the camera work of every shot: static, pan, tilt, zoom, tracking (translation with parallax), handheld (shake) or mixed, with a shake measure. |
|
Package scene detects hard cuts from the luma difference between consecutive thumbnails, with an adaptive threshold: a frame is a cut when its score is both high in absolute terms and much higher than its neighbours' (so that fast motion, which raises every score, does not trigger cuts).
|
Package scene detects hard cuts from the luma difference between consecutive thumbnails, with an adaptive threshold: a frame is a cut when its score is both high in absolute terms and much higher than its neighbours' (so that fast motion, which raises every score, does not trigger cuts). |
|
Package siti computes spatial and temporal perceptual information (SI/TI) as defined by ITU-T P.910.
|
Package siti computes spatial and temporal perceptual information (SI/TI) as defined by ITU-T P.910. |