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 ¶
- type AudioTrack
- type Kind
- type Layout
- type MissingDataError
- type Result
- func Image(r io.ReaderAt, size int64, label string) (*Result, error)
- func M2TS(r io.ReaderAt, size int64, label string) (res *Result, err error)
- func MP4(r io.ReaderAt, size int64, label string) (res *Result, err error)
- func Matroska(r io.Reader, label string) (res *Result, err error)
- func Path(path string) (*Result, error)
- type SubtitleTrack
- type VideoTrack
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 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 ¶
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
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
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.
type SubtitleTrack ¶
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.