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
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
type FLVProber ¶
type FLVProber struct{}
FLVProber implements the Prober interface for FLV containers
type MKVProber ¶
type MKVProber struct{}
MKVProber implements the Prober interface for MKV/WebM containers
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
type MP4Prober ¶
type MP4Prober struct{}
MP4Prober implements the Prober interface for MP4 containers
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 ¶
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 ¶
GetAudioChannelDescription returns human-readable audio channel description Examples: "Stereo", "5.1", "7.1"
func (*VideoInfo) GetResolution ¶
GetResolution returns human-readable resolution string Examples: "4K", "1080p", "720p", "SD"