Documentation
¶
Overview ¶
Package probe reads media facts (duration, codecs, tags) with ffprobe.
Index ¶
- Constants
- func ChannelLabel(n int) string
- func Damaged(ctx context.Context, ffmpeg, path string, durationMs int64, ...) bool
- func LeadingInt(s string) int
- func LowerPriority(pid int)
- func ResolutionLabel(w, h int) string
- type AudioStream
- type Chapter
- type MediaInfo
- type Prober
- type Result
- type Subtitle
- type VideoStream
Constants ¶
const MediaInfoVersion = 4
MediaInfoVersion goes up when Analyze learns something new, so files analyzed before are looked at again. 4 keeps the chapters themselves, not just how many there are.
Variables ¶
This section is empty.
Functions ¶
func ChannelLabel ¶
ChannelLabel names a channel count: mono, stereo, 5.1, 7.1.
func Damaged ¶ added in v0.2.4
func Damaged(ctx context.Context, ffmpeg, path string, durationMs int64, lowPriority func(pid int)) bool
Damaged tells a damaged file from a share that was just slow, after a background job's read of the file timed out: it jumps to a few points in the file (a tenth, half and nine tenths of the way in, or 1, 10 and 30 minutes when the length isn't known) and reads a second at each. A file that a jump times out on is damaged, say one whose seek index points past its end or whose end was never written. ffmpeg is FFmpeg's path, and lowPriority, when set, is called with each FFmpeg's process id.
func LeadingInt ¶
LeadingInt reads "3/12" or "03" as 3, the way track and disc tags are written.
func LowerPriority ¶ added in v0.1.3
func LowerPriority(pid int)
LowerPriority makes a running process give way to everything else on the machine, for CPU and (where the system allows) for disk.
func ResolutionLabel ¶
ResolutionLabel names a picture size the way people talk about it. Width counts as much as height, so a 1920×800 widescreen film is still 1080p.
Types ¶
type AudioStream ¶
type AudioStream struct {
Index int `json:"index"` // among the file's audio streams, as in FFmpeg's 0:a:N
Codec string `json:"codec"`
Profile string `json:"profile,omitempty"`
Channels int `json:"channels"`
ChannelLayout string `json:"channelLayout,omitempty"`
SampleRate int `json:"sampleRate,omitempty"`
BitDepth int `json:"bitDepth,omitempty"`
Bitrate int64 `json:"bitrate,omitempty"`
Atmos bool `json:"atmos,omitempty"`
DTSX bool `json:"dtsx,omitempty"`
Language string `json:"language,omitempty"`
Title string `json:"title,omitempty"`
Default bool `json:"default,omitempty"`
Forced bool `json:"forced,omitempty"`
Commentary bool `json:"commentary,omitempty"`
Descriptive bool `json:"descriptive,omitempty"` // audio description for the blind
}
type Chapter ¶ added in v0.1.2
type Chapter struct {
Title string `json:"title,omitempty"`
StartMs int64 `json:"startMs"`
EndMs int64 `json:"endMs"`
}
Chapter is a marked part of a file, with its own title.
type MediaInfo ¶
type MediaInfo struct {
Container string `json:"container"`
Size int64 `json:"size"`
DurationMs int64 `json:"durationMs"`
Bitrate int64 `json:"bitrate,omitempty"` // bits per second, all streams
Video []VideoStream `json:"video"`
Audio []AudioStream `json:"audio"`
Subtitles []Subtitle `json:"subtitles"`
Chapters int `json:"chapters,omitempty"`
// ChapterList is the file's chapters in order, for marks on the seek
// bar. The API moves it to the item's own chapters.
ChapterList []Chapter `json:"chapterList,omitempty"`
// CreditsMs is where the closing credits start, when a chapter says so.
// Players offer the next episode from there.
CreditsMs int64 `json:"creditsMs,omitempty"`
// IntroStartMs and IntroEndMs are where the intro (opening titles,
// theme song) is, when a chapter says so. Players offer to skip it.
IntroStartMs int64 `json:"introStartMs,omitempty"`
IntroEndMs int64 `json:"introEndMs,omitempty"`
Error string `json:"error,omitempty"` // set when ffprobe couldn't read the file
AnalyzedAt int64 `json:"analyzedAt"` // Unix seconds
}
MediaInfo is everything worth knowing about a file's streams, from a slower and more thorough look than the scanner's.
type Prober ¶
type Prober struct {
Path string
Timeout time.Duration
// LowPriority runs ffprobe at the lowest CPU and disk priority, for work
// in the background that nobody is waiting on.
LowPriority bool
}
type Result ¶
type Result struct {
DurationMs int64
Container string // first name ffprobe gives, e.g. "matroska" or "mov"
VideoCodec string
AudioCodec string
Width int
Height int
HasCover bool // an embedded picture, like album art in a FLAC or MP3
Tags map[string]string // lower-cased keys: title, artist, album_artist, album, track, disc, date
Subtitles []Subtitle // embedded subtitle streams, in file order
Chapters []Chapter // marked chapters, such as an audiobook's, in order
}
func (Result) SubtitleList ¶
SubtitleList is Subtitles, never nil, so it encodes as [] rather than null.
type Subtitle ¶
type Subtitle struct {
Index int `json:"index"` // among the file's subtitle streams, as in FFmpeg's 0:s:N
Codec string `json:"codec"`
Language string `json:"language,omitempty"` // as tagged, usually ISO 639-2 like "eng"
Title string `json:"title,omitempty"`
Default bool `json:"default,omitempty"`
Forced bool `json:"forced,omitempty"`
SDH bool `json:"sdh,omitempty"` // for the deaf and hard of hearing
}
Subtitle is an embedded subtitle stream.
type VideoStream ¶
type VideoStream struct {
Index int `json:"index"` // among the file's video streams, as in FFmpeg's 0:v:N
Codec string `json:"codec"`
Profile string `json:"profile,omitempty"`
Width int `json:"width"`
Height int `json:"height"`
Resolution string `json:"resolution"` // 4K, 1080p…, see ResolutionLabel
FrameRate float64 `json:"frameRate,omitempty"`
Bitrate int64 `json:"bitrate,omitempty"`
BitDepth int `json:"bitDepth,omitempty"`
PixFmt string `json:"pixFmt,omitempty"`
ColorPrimaries string `json:"colorPrimaries,omitempty"`
ColorTransfer string `json:"colorTransfer,omitempty"`
ColorSpace string `json:"colorSpace,omitempty"`
// HDR is "" for SDR, else dolby-vision, hdr10+, hdr10 or hlg. A Dolby
// Vision file says which HDR10 or HLG layer it falls back to in HDRBase.
HDR string `json:"hdr,omitempty"`
HDRBase string `json:"hdrBase,omitempty"`
DVProfile int `json:"dvProfile,omitempty"`
DVLevel int `json:"dvLevel,omitempty"`
Language string `json:"language,omitempty"`
Title string `json:"title,omitempty"`
Default bool `json:"default,omitempty"`
}