makemkv

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when something is not found.
	ErrNotFound = fmt.Errorf("not found")
)

Functions

func FindExe

func FindExe() (string, error)

FindExe attempts to return the path of the makemkvcon executable on Linux and Darwin operating systems.

func Grammar added in v0.5.0

func Grammar() string

Grammar returns an EBNF representation of the supported grammar.

func Maximums

func Maximums[S []E, E any, V cmp.Ordered](s S, f func(E) (V, error)) S

Maximums returns all elements of the slice that maximize the given function, i.e., where f(e) = max(f(e0), f(e1), ..., f(eN)).

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string with hours, minutes and seconds values separated by colons like "1:22:33".

func ParseLines

func ParseLines(r io.Reader) iter.Seq2[*Line, error]

ParseLines parses makemkvcon output lines from r. It returns a sequence of [*Line, error] where either Line is a parsed line or err is non-nil. The sequence ends after all lines have been parsed and r returns EOF. Individual line parsing errors do not trigger an early return.

Types

type Attribute added in v0.5.0

type Attribute struct {
	Pos lexer.Position

	// ID is an integer that identifies the attribute.
	ID int `@Int`

	// Code is an integer that corresponds to Value, if Value is an enumeration.
	Code int `"," @Int`

	// Value is the value of the attribute identified by ID.
	Value Str `"," @String`
}

Attribute is the common representation of the "CINFO", "TINFO" and "SINFO" makemkvcon output lines, which describe an attribute of a disc, title, or stream.

func (*Attribute) String added in v0.5.0

func (a *Attribute) String() string

type Con

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

Con is the interface for running makemkvcon commands.

func New

func New(cfg *Config) (*Con, error)

New returns a new Con.

If cfg.ExePath is empty, it will attempt to locate the executable automatically.

func (*Con) BackupTitle

func (c *Con) BackupTitle(ctx context.Context, driveIndex, titleIndex int, dstDir string) (iter.Seq2[*Line, error], error)

BackupTitle creates a backup of title titleIndex of drive driveIndex in dstDir. The directory is created automatically if necessary.

func (*Con) ListDrives

func (c *Con) ListDrives(ctx context.Context) (*LineIterator[[]*DriveScan], error)

ListDrives returns the list of drives detected by makemkvcon.

func (*Con) RunCmd

func (c *Con) RunCmd(ctx context.Context, args ...string) (iter.Seq2[*Line, error], error)

RunCmd runs an arbitrary makemkvcon command with the given args. It terminates when the context is canceled or the command terminates.

func (*Con) RunDefaultCmd

func (c *Con) RunDefaultCmd(ctx context.Context, args ...string) (iter.Seq2[*Line, error], error)

RunDefaultCmd calls RunCmd with default args in addition to the specified args. Default args include -r (machine-readable output), --minlength, and --profile.

func (*Con) ScanDrive

func (c *Con) ScanDrive(ctx context.Context, driveIndex int) (*LineIterator[*Disc], error)

ScanDrive returns information about the disc in the given drive. The driveIndex should be obtained from ListDrives.

type Config

type Config struct {
	// ExePath is the path to the makemkvcon executable. It must exist.
	ExePath string

	// ProfilePath is the path to a makemkv profile XML file. makemkvcon relies
	// on it for the app_DefaultSelectionString setting, which determines what
	// streams (video, audio, and subtitles) are selected by default. It must
	// exist if non-empty.
	ProfilePath string

	// ReadCacheSizeMB is the value that is passed with the --cache argument to
	// makemkvcon. It must be at least 1.
	ReadCacheSizeMB int64 `validate:"min=1"`

	// MinLengthSeconds is the value that is passed with the --minlength argument
	// to makemkvcon. It must be at least 1.
	//
	// It filters out titles with video streams less than the given length, which
	// is very useful for weeding out unimportant streams.
	MinLengthSeconds int64 `validate:"min=1"`
}

Config is the makemkvcon configuration.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate returns an error if the configuration is invalid.

type CurrentSubtask added in v0.5.0

type CurrentSubtask struct {
	Pos lexer.Position

	Task *Task `@@`
}

CurrentSubtask represents a makemkvcon "PRGC" output line, which describes the current sub-task.

type CurrentTask added in v0.5.0

type CurrentTask struct {
	Pos lexer.Position

	Task *Task `@@`
}

CurrentTask represents a makemkvcon "PRGT" output line, which describes the overall task being performed.

type Disc

type Disc struct {
	Info

	Titles []*Title
}

Disc is a sequence of titles plus some metadata.

func (*Disc) GetTitle

func (d *Disc) GetTitle(index int) *Title

GetTitle returns the title with the given index, creating it (and previous titles) if necessary.

func (*Disc) TitleCount

func (d *Disc) TitleCount() int

TitleCount returns the number of titles on the disc.

func (*Disc) TitlesWithAngle

func (d *Disc) TitlesWithAngle(targetAngle int) []*Title

TitlesWithAngle returns all titles with the given angle.

func (*Disc) TitlesWithLongestDuration

func (d *Disc) TitlesWithLongestDuration() []*Title

TitlesWithLongestDuration returns all titles that tie for maximum duration.

func (*Disc) TitlesWithMostChapters

func (d *Disc) TitlesWithMostChapters() []*Title

TitlesWithMostChapters returns all titles that tie for maximum number of chapters.

func (*Disc) TitlesWithMostStreams

func (d *Disc) TitlesWithMostStreams() []*Title

TitlesWithMostStreams returns all titles that tie for maximum number of streams.

type DiscInfo added in v0.5.0

type DiscInfo struct {
	Pos lexer.Position

	Attribute *Attribute `@@`
}

DiscInfoLine represents a makemkvcon "CINFO" output line, which provides information about a disc.

type DriveScan added in v0.5.0

type DriveScan struct {
	Pos lexer.Position

	Index      int `@Int`
	Visible    int `"," @Int`
	Enabled    int `"," @Int`
	Flags      int `"," @Int`
	DriveName  Str `"," @String`
	DiscTitle  Str `"," @String`
	VolumeName Str `"," @String`
}

DriveScan represents a makemkvcon "DRV" output line, which describes a disc drive.

type Info

type Info []*Attribute

Info is a slice of related Attributes.

func (Info) GetAttr

func (info Info) GetAttr(id defs.Attr) (string, error)

GetAttr returns the Value of the Attribute where ID matches id or ErrNotFound if such an attribute does not exist.

func (Info) GetAttrDefault

func (info Info) GetAttrDefault(id defs.Attr, defaultValue string) string

GetAttrDefault returns the Value of the Attribute where ID matches id or defaultValue if such an attribute does not exist.

func (Info) GetAttrDuration

func (info Info) GetAttrDuration(id defs.Attr) (time.Duration, error)

GetAttrDuration is like GetAttr, except it also attempts to convert the value to a time.Duration.

func (Info) GetAttrInt

func (info Info) GetAttrInt(id defs.Attr) (int, error)

GetAttrInto is like GetAttr, except it also attempts to convert the Value to an integer.

func (Info) GetCode

func (info Info) GetCode(id defs.Attr) (int, error)

GetCode returns the Code of the Attribute where ID matches id or ErrNotFound if such an attribute does not exist.

func (Info) GetCodeDefault

func (info Info) GetCodeDefault(id defs.Attr, defaultValue int) int

GetCodeDefault returns the Code of the Attribute where ID matches id or defaultValue if such an attribute does not exist.

type Line

type Line struct {
	Pos lexer.Position

	DriveScan      *DriveScan      `  "DRV"    ":" @@`
	Message        *Message        `| "MSG"    ":" @@`
	DiscInfo       *DiscInfo       `| "CINFO"  ":" @@`
	TitleInfo      *TitleInfo      `| "TINFO"  ":" @@`
	StreamInfo     *StreamInfo     `| "SINFO"  ":" @@`
	CurrentTask    *CurrentTask    `| "PRGT"   ":" @@`
	CurrentSubtask *CurrentSubtask `| "PRGC"   ":" @@`
	Progress       *Progress       `| "PRGV"   ":" @@`
	TitleCount     *TitleCount     `| "TCOUNT" ":" @@`
}

Line represents a single line of output from makemkvcon.

func ParseLine

func ParseLine(s string) (*Line, error)

ParseLine parses a single line of output from makemkvcon.

type LineIterator

type LineIterator[T any] struct {
	Seq iter.Seq2[*Line, error]
	// contains filtered or unexported fields
}

LineIterator is a generic type that represents the lines output by a makemkvcon command and the generic final result.

func (*LineIterator[T]) GetResult

func (li *LineIterator[T]) GetResult() (T, error)

GetResult returns the final result of the command.

type Message added in v0.5.0

type Message struct {
	Pos lexer.Position

	Code      int   `@Int`
	Flags     int   `"," @Int`
	NumParams int   `"," @Int`
	Message   Str   `"," @String`
	Format    Str   `"," @String`
	Params    []Str `( "," @String )*`
}

Message represents a makemkvcon "MSG" output line, which is an informational logging line.

type Output added in v0.5.0

type Output struct {
	Pos lexer.Position

	Lines []*Line `( @@ EOL )*`
}

Output represents the multi-line output of makemkvcon.

See https://makemkv.com/developers/usage.txt.

func ParseFile added in v0.5.0

func ParseFile(path string) (*Output, error)

ParseFile parses the multi-line output of makemkvcon from a file.

func ParseOutput added in v0.5.0

func ParseOutput(s string) (*Output, error)

ParseOutput parses multi-line output from makemkvcon.

type Progress added in v0.5.0

type Progress struct {
	Pos lexer.Position

	SubtaskValue int `@Int`
	TaskValue    int `"," @Int`

	// Max is a constant denominator used to calculate the progress percentage.
	Max int `"," @Int`
}

Progress represents a makemkvcon "PRGV" output line, which describes the progress of a task and sub-task.

func (*Progress) SubtaskProgress added in v0.5.0

func (l *Progress) SubtaskProgress() float64

SubtaskProgress returns the progress of the current sub-task as a percentage.

func (*Progress) TaskProgress added in v0.5.0

func (l *Progress) TaskProgress() float64

TaskProgress returns the progress of the overall task as a percentage.

type Str added in v0.5.0

type Str string

func (*Str) Capture added in v0.5.0

func (s *Str) Capture(values []string) error

func (*Str) String added in v0.5.0

func (s *Str) String() string

type Stream

type Stream struct {
	// Index is the index given by makemkv.
	Index int

	Info
}

Stream is a video, audio or subtitles stream. A Title is made up of multiple Streams.

func (*Stream) Type

func (s *Stream) Type() defs.TypeCode

Type returns the type code of the stream.

type StreamInfo added in v0.5.0

type StreamInfo struct {
	Pos lexer.Position

	TitleIndex  int        `@Int`
	StreamIndex int        `"," @Int`
	Attribute   *Attribute `"," @@`
}

StreamInfo represents an "SINFO" makemkvcon output line, which provides information about a stream.

type Task added in v0.5.0

type Task struct {
	Pos lexer.Position

	ID   int `@Int`
	Code int `"," @Int`
	Name Str `"," @String`
}

Task is the common representation for makemkvcon "PRGT" and "PRGC" output lines, which describe the current task and subtask, respectively.

type Title

type Title struct {
	// Index is the index given by makemkv. Title numbers appear to be
	// deterministic if makemkv is run with the same --minlength argument.
	Index int

	Info

	Streams []*Stream
}

Title is a collection of Streams plus some metadata. It is identified by an index number. A Disc is made up of multiple Titles.

Streams may be video, audio, or subtitles.

func (*Title) GetStream

func (t *Title) GetStream(index int) *Stream

GetStream returns the stream with the given index, creating it (and all prior streams) as necessary.

type TitleCount added in v0.5.0

type TitleCount struct {
	Pos lexer.Position

	Count int `@Int`
}

TitleCount represents a "TCOUNT" makemkvcon output line, which describes the number of titles found on a disc.

type TitleInfo added in v0.5.0

type TitleInfo struct {
	Pos lexer.Position

	TitleIndex int        `@Int`
	Attribute  *Attribute `"," @@`
}

TitleInfo represents a makemkvcon "TINFO" output line, which provides information about a title.

Directories

Path Synopsis
cmd
dumpebnf command
Package defs defines a subset of attributes and codes used by makemkv to describe discs, titles, and streams.
Package defs defines a subset of attributes and codes used by makemkv to describe discs, titles, and streams.

Jump to

Keyboard shortcuts

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