probe

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package probe identifies a video source from the little of it that a pre-download sample contains: a disc image's BDMV metadata, a Matroska file's header, an MP4 or QuickTime file's movie box, or a bare transport stream's program tables. It reports what the container states and never guesses.

A Blu-ray image keeps its UDF directory at the front and its BDMV metadata (playlists, clip info) at the end, so the first and last pieces of a torrent are enough; a Matroska file states its tracks in its first kilobytes. Reads outside what the caller has are ordinary errors: a partial source never panics, and never yields a plausible wrong answer.

Nothing here decodes video: the package depends on the container readers alone, not on the MVC decoder or its assembly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioTrack

type AudioTrack struct {
	Codec       string // "TRUE-HD", "DTS", "E-AC3 (DD+)", … or the raw CodecID
	Language    string // ISO 639-2, empty when unstated
	Channels    int    // zero when unstated
	SampleRate  float64
	BitrateKbps int // zero when the stream does not state it
}

AudioTrack is an audio stream.

type Kind

type Kind int

Kind is what sort of source was probed.

const (
	KindUnknown  Kind = iota
	KindDisc          // UDF/BDMV image or directory
	KindMatroska      // Matroska file
	KindMP4           // MP4 or QuickTime file
	// KindTransportStream is a bare transport stream (.m2ts, .mts, .ts): a
	// Blu-ray clip or an MVC remux on its own.
	KindTransportStream
)

type Layout

type Layout int

Layout is how a source carries its views.

const (
	Layout2D         Layout = iota // the source states it is not stereoscopic
	LayoutMVC                      // dependent view: a Blu-ray 3D disc, or MVC in MKV
	LayoutSideBySide               // both eyes side by side in each frame
	LayoutTopBottom                // both eyes one above the other
	LayoutOther                    // stereoscopic, but not a layout named here
	// LayoutMVHEVC is multiview HEVC: the second eye a layer of its own,
	// as Apple's spatial video carries it. Each eye is a full picture, and
	// a plain HEVC decoder shows the base view alone.
	LayoutMVHEVC
)

type MissingDataError

type MissingDataError struct {
	// Offset and Length are the first read that failed.
	Offset, Length int64
	// Err is what the reader returned; Probe is the error it led to.
	Err, Probe error
}

MissingDataError says a probe failed for want of bytes the caller's reader could not supply.

func (*MissingDataError) Error

func (e *MissingDataError) Error() string

func (*MissingDataError) Unwrap

func (e *MissingDataError) Unwrap() []error

Unwrap gives both the reader's error and the probe's.

type Result

type Result struct {
	Kind     Kind
	Source   string        // label for messages
	Duration time.Duration // zero when the container does not say

	// Is3D is explicit: false means the source states it is 2D, which is as
	// useful an answer as true. Layout is Layout2D exactly when Is3D is
	// false.
	Is3D   bool
	Layout Layout
	// BaseViewRight is the disc's mvc_base_view_R_flag. Discs only.
	BaseViewRight bool

	Video    []VideoTrack
	Audio    []AudioTrack
	Subtitle []SubtitleTrack
}

Result is what a probe found. Fields the source does not state are zero. New fields may be added; existing ones keep their meaning.

func Image

func Image(r io.ReaderAt, size int64, label string) (*Result, error)

Image probes a UDF/BDMV disc image. size is the image's full length. The caller owns r and Image does not close it.

When the probe fails because a read of r failed — the sample lacks a piece the directory or the metadata is in — the error is a *MissingDataError naming the bytes that were wanted, so the caller can fetch them and try again.

func M2TS added in v0.19.0

func M2TS(r io.ReaderAt, size int64, label string) (res *Result, err error)

M2TS probes a bare transport stream (.m2ts, .mts, .ts: a Blu-ray clip or an MVC remux on its own, 192- or 188-byte packets) from its start: the PAT, then the PMT, which repeat every few hundred milliseconds, so the first piece of a download is enough. The streams are the PMT's, named as a disc's; a dependent view (stream type 0x20) makes it 3D in MVC, a plain AVC, HEVC or VC-1 stream 2D. The duration is not read. size is the file's full length. The caller owns r.

When the probe fails because a read of r failed, the error is a *MissingDataError naming the bytes that were wanted, as Image's is.

func MP4 added in v0.13.0

func MP4(r io.ReaderAt, size int64, label string) (res *Result, err error)

MP4 probes an MP4 or QuickTime file (an ISO base media file): its tracks from the movie box, which sits at the file's start or end, so the first and last pieces of a download are enough. size is the file's full length. The caller owns r and MP4 does not close it.

MV-HEVC (Apple's spatial video) is told by its second layer's configuration (lhvC) and reported as LayoutMVHEVC, unless Apple's vexu box names one eye only; a frame holding both eyes is told by its st3d box. When a read fails because the sample lacks a piece, the error is a *MissingDataError naming the bytes wanted.

func Matroska

func Matroska(r io.Reader, label string) (res *Result, err error)

Matroska probes a Matroska file, reading only as far as its header (and, within a small budget, its first frames), so a prefix of the file is enough.

func Path

func Path(path string) (*Result, error)

Path probes whatever is at path, choosing by extension and by whether it is a directory: a BDMV folder or .iso image, a .mkv/.mk3d file, an .mp4/.mov/.m4v file, or an .m2ts/.mts/.ts transport stream.

type SubtitleTrack

type SubtitleTrack struct {
	Codec    string
	Language string
}

SubtitleTrack is a subtitle stream.

type VideoTrack

type VideoTrack struct {
	Codec         string // "H.264", "MVC", "HEVC", … or the raw CodecID
	Width, Height int    // zero when unstated
	// BitDepth is the luma bit depth: on a disc, the one the format allows
	// the coding (8, or 10 for Ultra HD Blu-ray's HEVC); in Matroska, the
	// Colour element's or the codec configuration's. Zero when unstated.
	BitDepth int
}

VideoTrack is a video stream.

Jump to

Keyboard shortcuts

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