Documentation
¶
Overview ¶
Package mediainfo exposes go-mediainfo as an importable library.
Import path:
import mediainfo "github.com/autobrr/go-mediainfo"
Typical flow:
- Analyze one or more files with AnalyzeFile/AnalyzeFiles.
- Render reports with Render and an OutputFormat.
Index ¶
- func FormatVersion(version string) string
- func InfoParameters() string
- func Render(reports []Report, format OutputFormat) (string, error)
- func RenderWithOptions(reports []Report, format OutputFormat, options RenderOptions) (string, error)
- func SetAppVersion(version string)
- type AnalyzeOption
- type Field
- type OutputFormat
- type RenderOptions
- type Report
- func AnalyzeFile(path string, options ...AnalyzeOption) (Report, error)
- func AnalyzeFileContext(ctx context.Context, path string, options ...AnalyzeOption) (Report, error)
- func AnalyzeFiles(paths []string, options ...AnalyzeOption) ([]Report, error)
- func AnalyzeFilesWithCount(paths []string, options ...AnalyzeOption) ([]Report, int, error)
- type Stream
- type StreamKind
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatVersion ¶
FormatVersion normalizes the version label to MediaInfo style.
func InfoParameters ¶
func InfoParameters() string
InfoParameters returns the supported info parameter listing.
func Render ¶
func Render(reports []Report, format OutputFormat) (string, error)
Render renders reports with the selected format.
func RenderWithOptions ¶ added in v0.5.0
func RenderWithOptions(reports []Report, format OutputFormat, options RenderOptions) (string, error)
RenderWithOptions renders reports with the selected format and options. It returns an error when format is unsupported. Language affects text output only; other formats remain unchanged.
func SetAppVersion ¶
func SetAppVersion(version string)
SetAppVersion sets the version shown in rendered metadata.
Types ¶
type AnalyzeOption ¶
type AnalyzeOption func(*core.AnalyzeOptions)
AnalyzeOption configures parsing behavior.
func WithParseSpeed ¶
func WithParseSpeed(value float64) AnalyzeOption
WithParseSpeed sets ParseSpeed (0..1). If unset, default is 0.5.
func WithTestContinuousFileNames ¶
func WithTestContinuousFileNames(enabled bool) AnalyzeOption
WithTestContinuousFileNames enables MediaInfo-style continuous file probing.
type OutputFormat ¶
type OutputFormat string
OutputFormat is a renderer output type.
const ( // OutputText renders text output. OutputText OutputFormat = "TEXT" // OutputJSON renders JSON output. OutputJSON OutputFormat = "JSON" // OutputXML renders XML output. OutputXML OutputFormat = "XML" // OutputOldXML renders old XML output. OutputOldXML OutputFormat = "OLDXML" // OutputHTML renders HTML output. OutputHTML OutputFormat = "HTML" // OutputCSV renders CSV output. OutputCSV OutputFormat = "CSV" // OutputEBUCore renders EBUCore output. OutputEBUCore OutputFormat = "EBUCORE" // OutputEBUCoreJSON renders EBUCore JSON output. OutputEBUCoreJSON OutputFormat = "EBUCORE_JSON" // OutputPBCore renders PBCore output. OutputPBCore OutputFormat = "PBCORE" // OutputPBCore2 renders PBCore2 output. OutputPBCore2 OutputFormat = "PBCORE2" // OutputGraphSVG renders Graph SVG output. OutputGraphSVG OutputFormat = "GRAPH_SVG" // OutputGraphDOT renders Graph DOT output. OutputGraphDOT OutputFormat = "GRAPH_DOT" )
type RenderOptions ¶ added in v0.5.0
type RenderOptions struct {
// Language selects the text projection. "raw" enables MediaInfo raw labels
// and values; the zero value and other languages retain friendly text.
// Non-text renderers ignore Language.
Language string
// InformVersion appends MediaInfo's ReportBy footer to raw-language text output.
InformVersion bool
}
RenderOptions configures representation-specific rendering behavior.
type Report ¶
Report is the analysis result for one input path.
func AnalyzeFile ¶
func AnalyzeFile(path string, options ...AnalyzeOption) (Report, error)
AnalyzeFile analyzes one file or directory path.
Example ¶
package main
import (
"fmt"
mediainfo "github.com/autobrr/go-mediainfo"
)
func main() {
report, err := mediainfo.AnalyzeFile("samples/sample.mp4")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(report.General.Kind)
}
Output: General
func AnalyzeFileContext ¶ added in v0.8.0
AnalyzeFileContext behaves like AnalyzeFile but observes ctx between reads of the input file, so a caller can bound an analysis that would otherwise block on slow storage. It returns ctx's error when the context ends before the analysis completes; ctx must be non-nil. A read already blocked in the OS still returns only when the OS completes it, and reads of any file other than the input are not cancellation-checked.
func AnalyzeFiles ¶
func AnalyzeFiles(paths []string, options ...AnalyzeOption) ([]Report, error)
AnalyzeFiles analyzes multiple paths.
func AnalyzeFilesWithCount ¶
func AnalyzeFilesWithCount(paths []string, options ...AnalyzeOption) ([]Report, int, error)
AnalyzeFilesWithCount analyzes multiple paths and returns report count.
type StreamKind ¶
type StreamKind = core.StreamKind
StreamKind identifies a MediaInfo stream category.
const ( // StreamGeneral is the container-level stream. StreamGeneral StreamKind = core.StreamGeneral // StreamVideo is a video stream. StreamVideo StreamKind = core.StreamVideo // StreamAudio is an audio stream. StreamAudio StreamKind = core.StreamAudio // StreamText is a subtitle/caption stream. StreamText StreamKind = core.StreamText // StreamImage is an image stream. StreamImage StreamKind = core.StreamImage // StreamMenu is a menu/chapters stream. StreamMenu StreamKind = core.StreamMenu )