mediainfo

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: GPL-2.0 Imports: 3 Imported by: 0

README

███╗   ███╗███████╗██████╗ ██╗ █████╗ ██╗███╗   ██╗███████╗ ██████╗
████╗ ████║██╔════╝██╔══██╗██║██╔══██╗██║████╗  ██║██╔════╝██╔═══██╗
██╔████╔██║█████╗  ██║  ██║██║███████║██║██╔██╗ ██║█████╗  ██║   ██║
██║╚██╔╝██║██╔══╝  ██║  ██║██║██╔══██║██║██║╚██╗██║██╔══╝  ██║   ██║
██║ ╚═╝ ██║███████╗██████╔╝██║██║  ██║██║██║ ╚████║██║     ╚██████╔╝
╚═╝     ╚═╝╚══════╝╚═════╝ ╚═╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝╚═╝      ╚═════╝

Go rewrite of MediaInfo CLI.

Installation

  • Homebrew (macOS):
brew tap autobrr/go-mediainfo https://github.com/autobrr/go-mediainfo
brew install --cask autobrr/go-mediainfo/mediainfo

Note: Homebrew’s official MediaInfo install can conflict (media-info / mediainfo). This cask also links go-mediainfo so you can run both:

go-mediainfo version
  • Go install (requires Go toolchain):
go install github.com/autobrr/go-mediainfo/cmd/mediainfo@latest
  • Latest release (one-liner, Linux x86_64):
    • Replace linux_amd64 with linux_arm64, darwin_amd64, or darwin_arm64 as needed.
curl -sL "$(curl -s https://api.github.com/repos/autobrr/go-mediainfo/releases/latest | grep browser_download_url | grep linux_amd64 | cut -d\" -f4)" | tar -xz -C /usr/local/bin

Library Usage (Go)

go get github.com/autobrr/go-mediainfo@latest
import (
	"fmt"

	mediainfo "github.com/autobrr/go-mediainfo"
)

func main() {
	reports, err := mediainfo.AnalyzeFiles(
		[]string{"movie.mkv"},
		mediainfo.WithParseSpeed(0.5),
	)
	if err != nil {
		panic(err)
	}

	out, err := mediainfo.Render(reports, mediainfo.OutputJSON)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
}

Usage

Recommended (likely what you want):

mediainfo /path/to/file
mediainfo /path/to/file --Output=JSON --Language=raw
mediainfo /path/to/file --Output=JSON --Language=raw --ParseSpeed=0.5
mediainfo /path/to/dir
mediainfo --Info-Parameters
mediainfo --Version
mediainfo update
mediainfo version

Path is required (file or directory).

Default output: text. Footer includes ReportBy : go-mediainfo - vX.Y.Z.

Options

  • --Output=... (TEXT/JSON/XML/OLDXML/HTML/CSV/EBUCore/EBUCore_JSON/PBCore/PBCore2/Graph_Svg/Graph_Dot)
  • --Language=raw (non-translated unique identifiers; recommended for parity)
  • -lang=raw (alias for --Language=raw)
  • --LogFile=... (write output to a file)
  • --BOM (write UTF-8 BOM on Windows)
  • --ParseSpeed=0..1 (speed/accuracy tradeoff; default 0.5)
  • --File_TestContinuousFileNames=0|1 (MediaInfo-style continuous filename probing; default 0)
  • --Help, --Help-Output
  • --Info-Parameters
  • -f, --Full (reserved; currently no-op)

Commands

  • update (self-update this binary; release builds only)
  • version (print go-mediainfo version)

License

GPL-2.0-or-later. See LICENSE.

Documentation

Overview

Package mediainfo exposes go-mediainfo as an importable library.

Import path:

import mediainfo "github.com/autobrr/go-mediainfo"

Typical flow:

  1. Analyze one or more files with AnalyzeFile/AnalyzeFiles.
  2. Render reports with Render and an OutputFormat.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatVersion

func FormatVersion(version string) string

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 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 Field

type Field = core.Field

Field represents one MediaInfo field/value pair.

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 Report

type Report = core.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 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 Stream

type Stream = core.Stream

Stream represents one parsed stream (General/Video/Audio/Text/Menu).

type StreamKind

type StreamKind = core.StreamKind
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
)

Directories

Path Synopsis
cmd
mediainfo command
internal
cli

Jump to

Keyboard shortcuts

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