Skip to content

About

A Go rewrite of the MediaInfo CLI.

Topics

Resources

Stars

22 stars

Watchers

1 watching

Forks

Repository files navigation

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

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 is separated from media details by a blank line and uses the projection's aligned label column: ReportBy ... : go-mediainfo - vX.Y.Z.

JSON and XML language values use normalized primary codes and retain the source's script/region spelling: en-us stays en-us. Normal text and HTML use the applicable reference's language names; raw text uses codes with display suffixes such as en (US). DVD uses the v26.10 names and other containers use v23.04. Menu language lists retain empty positions and repeated members. MP4 track-backed chapter menus use their own track's language; an independent chpl list does not inherit a language.

Ogg LANGUAGE comments retain producer order and duplicates. A value starting with Director supplies the stream's language detail; otherwise a nonempty bracketed code supplies its language. Fields-only library reports preserve an ambiguous friendly name such as Ndebele as text, because it cannot identify which original code produced that name. Parsed reports retain their code.

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, except automatic DVD title-VOB continuation)
  • --Help, --Help-Output
  • --Info-Parameters
  • -f, --Full (reserved; currently no-op)

Automatic continuation is limited to recognized VTS_nn_1.VOB title sets and uses the v26.10 size eligibility bounds. Passing 0 disables continuation when opening a VOB directly. An IFO opens its title VOB with the default DVD continuation behavior, independently of this outer option.

Embedded metadata safety

Embedded attachments and cover art are inspected in memory only; they are never extracted, written, or executed. Per-file parsing limits embedded assets to 256, attachment names to 4 KiB each, MIME values to 1 KiB each, and retained metadata strings to 1 MiB total. Matroska image inspection retains at most 4 MiB per image and 32 MiB total; ID3 image probes retain at most 64 KiB each; ICC decompression is capped at 4 MiB. FLAC picture payloads are skipped after their bounded headers. MP4 reads the major brand and up to 256 compatible brands from the first complete ftyp header and skips the remainder of the box.

Malformed, truncated, unknown-sized, or over-limit embedded metadata is omitted while valid audio/video tracks continue parsing. This intentionally differs from upstream output for hostile inputs. Text and CSV outputs visibly escape control characters; CSV also neutralizes formula-leading metadata and formula-bearing injected cells. JSON continues to use Go JSON escaping.

Commands

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

License

GPL-2.0-or-later. See LICENSE.

About

A Go rewrite of the MediaInfo CLI.

Topics

Resources

Stars

22 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages