mediainfo

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 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 mediainfo provides ffprobe-based video file metadata scanning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Container    string  `json:"container"`     // e.g. "mkv", "mp4"
	DurationSecs float64 `json:"duration_secs"` // total duration
	VideoBitrate int64   `json:"video_bitrate"` // bits/sec (from format or stream)

	// Video stream (primary)
	Codec      string `json:"codec"` // normalised: "x265", "x264", "AV1"
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	Resolution string `json:"resolution"`  // normalised: "2160p", "1080p", "720p", "SD"
	ColorSpace string `json:"color_space"` // e.g. "bt2020nc", "bt709"
	HDRFormat  string `json:"hdr_format"`  // "HDR10", "Dolby Vision", "SDR"
	BitDepth   int    `json:"bit_depth"`   // 8, 10, 12

	// Audio (primary stream)
	AudioCodec    string `json:"audio_codec"`    // e.g. "eac3", "dts", "aac"
	AudioChannels int    `json:"audio_channels"` // 2, 6, 8
}

Result holds the actual technical metadata extracted from a video file by ffprobe. All fields are best-effort — missing streams leave fields at zero values.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner wraps ffprobe for video file metadata extraction. A Scanner with an empty ffprobePath is permanently disabled; all methods are safe to call on a disabled scanner.

func New

func New(ffprobePath string, timeout time.Duration) *Scanner

New creates a Scanner. ffprobePath may be empty (search $PATH) or an absolute/relative path. If the resolved binary is not found, the scanner is created in disabled state (Available() returns false).

func (*Scanner) Available

func (s *Scanner) Available() bool

Available reports whether ffprobe was found and scanning is enabled.

func (*Scanner) FFprobePath

func (s *Scanner) FFprobePath() string

FFprobePath returns the resolved path to ffprobe, or "" if unavailable.

func (*Scanner) Scan

func (s *Scanner) Scan(ctx context.Context, filePath string) (*Result, error)

Scan runs ffprobe on filePath and returns the parsed metadata. Returns an error if the scanner is unavailable or ffprobe fails.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides mediainfo scanning backed by the database.

func NewService

func NewService(scanner *Scanner, q dbgen.Querier, logger *slog.Logger) *Service

NewService creates a Service. scanner may be a disabled Scanner (Available() returns false); in that case ScanFile and ScanAll are no-ops.

func (*Service) Available

func (s *Service) Available() bool

Available reports whether the underlying scanner is operational.

func (*Service) FFprobeVersion

func (s *Service) FFprobeVersion() string

FFprobeVersion returns the resolved ffprobe path for display, or "".

func (*Service) ScanAll

func (s *Service) ScanAll(ctx context.Context) (int, error)

ScanAll scans every movie_file where mediainfo_json is empty. It returns the number of files successfully scanned. Intended for on-demand "scan all" from the settings page.

func (*Service) ScanFile

func (s *Service) ScanFile(ctx context.Context, fileID, filePath string) error

ScanFile scans one file by its database ID and file path, updating the movie_files row with the resulting mediainfo JSON.

Jump to

Keyboard shortcuts

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