thumbs

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 18 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 thumbs makes the pictures the players show above the seek bar while someone scrubs: a small frame every few seconds of each video, packed into JPEG sheets of Across by Down frames so a player loads a handful of images rather than hundreds.

FFmpeg reads only the video's keyframes, at the lowest CPU and disk priority. For most files it reads the file once, front to back; for files so big that would mean reading many megabytes per picture (4K remuxes on a network share), it jumps to each point instead. HDR video is tone mapped, so its pictures don't look washed out.

The sheets live in the data folder, one folder per video, and the database says how they're laid out (see store.Thumbnails).

Index

Constants

View Source
const Version = 1

Version goes up when the pictures change enough that videos should get new ones.

Variables

View Source
var (
	Width  = 240 // of one picture; the height follows the video's shape
	Across = 10  // pictures across one sheet
	Down   = 10  // and down

)

Sizes and timings, variables so tests can change them.

Functions

func Interval

func Interval(durationMs int64) time.Duration

Interval is how far apart a video's pictures are.

func Key

func Key(f store.ThumbnailFile) string

Key is what a video's pictures are stored under, see store.MediaKey.

Types

type Generator

type Generator struct {
	Store  *store.Store
	FFmpeg string
	Dir    string
	Log    *slog.Logger
	// LowPriority is called with each FFmpeg's process id.
	LowPriority func(pid int)
	// contains filtered or unexported fields
}

Generator makes the pictures and keeps track of them.

func (*Generator) Clean

func (g *Generator) Clean(ctx context.Context)

Clean deletes the pictures of videos that are gone, and anything left over from making pictures when the server stopped.

func (*Generator) Done

func (g *Generator) Done(f store.ThumbnailFile) bool

Done says whether a video's pictures are made, as it is now, and still there: a data folder that was emptied, as on a server whose data folder isn't kept, means making them again.

func (*Generator) Make

func (g *Generator) Make(ctx context.Context, f store.ThumbnailFile) bool

Make makes one video's pictures and stores them. It reports whether it stored anything.

func (*Generator) Mode

func (g *Generator) Mode(ctx context.Context) (Mode, error)

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

func (*Generator) Pass

func (g *Generator) Pass(ctx context.Context, next func(f store.ThumbnailFile) bool) (int, error)

Pass makes the pictures of every video that needs them, in id order. Before each it calls next, which returns false to stop the pass (paused, or shutting down). It returns how many videos it made pictures of.

func (*Generator) Request

func (g *Generator) Request(ctx context.Context, id int64) bool

Request has a video's pictures made soon, ahead of the background pass, because someone is playing it. It reports whether they're on their way.

func (*Generator) Serve

func (g *Generator) Serve(ctx context.Context)

Serve makes the pictures Request asks for, one video at a time, until ctx ends.

func (*Generator) SetMode

func (g *Generator) SetMode(ctx context.Context, m Mode) error

func (*Generator) SheetPath

func (g *Generator) SheetPath(id int64, n int) string

SheetPath is where a video's nth sheet is.

type Mode

type Mode string

Mode is when pictures are made, an admin setting.

const (
	// All makes pictures of every video in the background, after the media
	// analysis. The default.
	All Mode = "all"
	// OnPlay makes a video's pictures the first time someone plays it.
	OnPlay Mode = "onPlay"
	// Off makes none, and players show no pictures.
	Off Mode = "off"
)

Jump to

Keyboard shortcuts

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