mediainfo

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AVIProber

type AVIProber struct{}

AVIProber implements the Prober interface for AVI containers

func NewAVIProber

func NewAVIProber() *AVIProber

NewAVIProber creates a new AVI prober

func (*AVIProber) CanProbe

func (p *AVIProber) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*AVIProber) Name

func (p *AVIProber) Name() string

Name returns the prober identifier

func (*AVIProber) Probe

func (p *AVIProber) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the AVI file

type CLIProber

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

CLIProber implements the Prober interface using MediaInfo CLI

func NewCLIProber

func NewCLIProber(cfg *MediaInfoConfig) *CLIProber

NewCLIProber creates a new CLI prober

func (*CLIProber) CanProbe

func (p *CLIProber) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*CLIProber) Name

func (p *CLIProber) Name() string

Name returns the prober identifier

func (*CLIProber) Probe

func (p *CLIProber) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the file using MediaInfo CLI

type FLVProber

type FLVProber struct{}

FLVProber implements the Prober interface for FLV containers

func NewFLVProber

func NewFLVProber() *FLVProber

NewFLVProber creates a new FLV prober

func (*FLVProber) CanProbe

func (p *FLVProber) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*FLVProber) Name

func (p *FLVProber) Name() string

Name returns the prober identifier

func (*FLVProber) Probe

func (p *FLVProber) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the FLV file

type MKVProber

type MKVProber struct{}

MKVProber implements the Prober interface for MKV/WebM containers

func NewMKVProber

func NewMKVProber() *MKVProber

NewMKVProber creates a new MKV prober

func (*MKVProber) CanProbe

func (p *MKVProber) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*MKVProber) Name

func (p *MKVProber) Name() string

Name returns the prober identifier

func (*MKVProber) Probe

func (p *MKVProber) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the MKV file

type MOVProber

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

MOVProber implements the Prober interface for QuickTime MOV containers MOV files use ISO Base Media File Format, same as MP4

func NewMOVProber

func NewMOVProber() *MOVProber

NewMOVProber creates a new MOV prober

func (*MOVProber) CanProbe

func (p *MOVProber) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*MOVProber) Name

func (p *MOVProber) Name() string

Name returns the prober identifier

func (*MOVProber) Probe

func (p *MOVProber) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the MOV file

type MP4Prober

type MP4Prober struct{}

MP4Prober implements the Prober interface for MP4 containers

func NewMP4Prober

func NewMP4Prober() *MP4Prober

NewMP4Prober creates a new MP4 prober

func (*MP4Prober) CanProbe

func (p *MP4Prober) CanProbe(header []byte) bool

CanProbe checks if this prober can handle the file based on header

func (*MP4Prober) Name

func (p *MP4Prober) Name() string

Name returns the prober identifier

func (*MP4Prober) Probe

func (p *MP4Prober) Probe(f *os.File) (*VideoInfo, error)

Probe extracts metadata from the MP4 file

type MediaInfoConfig

type MediaInfoConfig struct {
	CLIEnabled bool   // Enable MediaInfo CLI fallback (default: false)
	CLIPath    string // Path to mediainfo binary (default: "mediainfo")
	CLITimeout int    // Timeout in seconds (default: 30)
}

MediaInfoConfig holds configuration for MediaInfo functionality

func DefaultMediaInfoConfig

func DefaultMediaInfoConfig() *MediaInfoConfig

DefaultMediaInfoConfig returns default configuration

type Prober

type Prober interface {
	// Name returns the prober identifier (e.g., "mp4", "mkv", "avi")
	Name() string

	// CanProbe checks if this prober can handle the file
	// Returns true if file header matches this format
	CanProbe(header []byte) bool

	// Probe extracts metadata from the file
	// Returns VideoInfo with as much information as possible
	Probe(f *os.File) (*VideoInfo, error)
}

Prober defines the interface for video metadata extraction

type ProberRegistry

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

ProberRegistry manages available probers and fallback logic

func NewProberRegistry

func NewProberRegistry(cfg *MediaInfoConfig) *ProberRegistry

NewProberRegistry creates registry with all native parsers

func (*ProberRegistry) FindProber

func (r *ProberRegistry) FindProber(header []byte) Prober

FindProber returns appropriate prober for file header Returns nil if no prober can handle the format

func (*ProberRegistry) ProbeWithFallback

func (r *ProberRegistry) ProbeWithFallback(f *os.File) (*VideoInfo, error)

ProbeWithFallback tries native parser first, falls back to CLI if available

func (*ProberRegistry) Register

func (r *ProberRegistry) Register(p Prober)

Register adds a prober to the registry

type VideoInfo

type VideoInfo struct {
	// Video properties
	VideoCodec  string  // "h264", "hevc", "vp9", etc.
	Width       int     // Video width in pixels (e.g., 1920)
	Height      int     // Video height in pixels (e.g., 1080)
	Duration    float64 // Duration in seconds
	Bitrate     int     // Bitrate in kbps (computed from file size and duration)
	AspectRatio float64 // Aspect ratio (computed from width/height)
	FrameRate   float64 // Frames per second

	// Audio properties
	AudioCodec    string // "aac", "mp3", "ac3", etc.
	AudioChannels int    // Number of audio channels (2 = stereo, 6 = 5.1)
	SampleRate    int    // Audio sample rate (e.g., 48000, 44100)

	// Container
	Container string // "mp4", "mkv", "avi", etc.
}

VideoInfo contains metadata extracted from a video file

func Analyze

func Analyze(filePath string) (*VideoInfo, error)

Analyze extracts metadata from a video file using the ProberRegistry Supports: MP4, MKV, MOV, AVI, FLV Falls back to MediaInfo CLI if enabled and native parsers fail Returns partial info if some fields are unavailable

func AnalyzeWithConfig

func AnalyzeWithConfig(filePath string, cfg *MediaInfoConfig) (*VideoInfo, error)

AnalyzeWithConfig extracts metadata using custom configuration

func (*VideoInfo) GetAudioChannelDescription

func (v *VideoInfo) GetAudioChannelDescription() string

GetAudioChannelDescription returns human-readable audio channel description Examples: "Stereo", "5.1", "7.1"

func (*VideoInfo) GetResolution

func (v *VideoInfo) GetResolution() string

GetResolution returns human-readable resolution string Examples: "4K", "1080p", "720p", "SD"

Jump to

Keyboard shortcuts

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