Documentation
¶
Overview ¶
Package probe reads what a source file actually is, using ffprobe.
Index ¶
- func KeyframeBefore(ctx context.Context, ffprobePath, path string, at, window time.Duration) (keyframe time.Duration, found bool, err error)
- func StoreCrop(path string, key Key, start, window time.Duration, rect crop.CropRect)
- func StorePeak(path string, key Key, start, window time.Duration, peak float64)
- type DolbyVision
- type Info
- type Key
- type Track
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyframeBefore ¶ added in v0.4.0
func KeyframeBefore( ctx context.Context, ffprobePath, path string, at, window time.Duration, ) (keyframe time.Duration, found bool, err error)
KeyframeBefore finds the last keyframe at or before a time.
Only a window before the time is read, so a source whose keyframes are far apart has none to offer. The time is rounded up to the millisecond, because clip marks carry milliseconds, and a mark rounded down would land before the keyframe and seek to the one before it.
Parameters:
- ctx: Cancellation and deadline for the read.
- ffprobePath: Path to the ffprobe binary.
- path: Media file path.
- at: The time the keyframe may not be after.
- window: How far before at the keyframe may be.
Returns:
- keyframe: The keyframe's time, rounded up to the millisecond.
- found: False when no keyframe lies in the window.
- err: Non-nil when ffprobe cannot read the file.
func StoreCrop ¶
StoreCrop caches a crop rectangle, but only if the source file is unchanged since the analysis read its identity.
Parameters:
- path: Cleaned source path, re-read to confirm the identity.
- key: Cache identity of the source file.
- start: Seek offset.
- window: Sampling window.
- rect: Result to store.
Types ¶
type DolbyVision ¶ added in v0.4.0
type DolbyVision struct {
// Present reports that the stream carries a configuration record.
Present bool `json:"present"`
// Profile is the Dolby Vision profile, such as 5, 7, or 8.
Profile int `json:"profile"`
// BaseLayerCompatibility is the base layer's signal compatibility id:
// 0 for none, 1 for HDR10, 2 for SDR, 4 for HLG, and 6 for UHD Blu-ray.
BaseLayerCompatibility int `json:"base_layer_compatibility"`
}
DolbyVision is a stream's Dolby Vision configuration record.
type Info ¶
type Info struct {
Duration time.Duration `json:"duration"`
Width int `json:"width"`
Height int `json:"height"`
VideoCodec string `json:"video_codec"`
AudioCodec string `json:"audio_codec"`
Format string `json:"format"`
BitRate int64 `json:"bit_rate"`
ColorTransfer string `json:"color_transfer"`
// PixelFormat is the video stream's pixel format, such as yuv420p.
PixelFormat string `json:"pixel_format"`
AudioTracks []Track `json:"audio_tracks"`
// DolbyVision is the video stream's Dolby Vision configuration, the zero
// value when the stream carries none.
DolbyVision DolbyVision `json:"dolby_vision"`
// MaxCLLNits is the video stream's MaxCLL in nits, 0 when it is unknown.
MaxCLLNits float64 `json:"max_cll_nits"`
// MasteringMaxNits is the mastering display's peak in nits, 0 when it is
// unknown.
MasteringMaxNits float64 `json:"mastering_max_nits"`
}
Info represents media file information.
func Probe ¶
Probe reads a media file for information.
Parameters:
- ctx: Cancellation and deadline for the probe.
- ffprobePath: Path to the ffprobe binary.
- path: Media file path.
Returns:
- info: The probed media information.
- err: Non-nil when the file cannot be probed.
func (Info) NeedsDolbyVisionReshaping ¶ added in v0.4.0
NeedsDolbyVisionReshaping reports whether the video is Dolby Vision with no displayable base layer, such as profile 5.
Its base layer is in Dolby's own color space and only looks right after the Dolby Vision reshaping, which ffmpeg's decoder does not apply.
Returns:
- needs: True for profile 5, or for any base layer compatible with nothing.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a probed file's identity on disk.
func KeyFor ¶
KeyFor builds the cache identity for a path, reporting whether the file can be identified on disk.
Parameters:
- path: Media file path.
Returns:
- key: The cache identity for the file.
- ok: False when the file cannot be stat'd.
func (Key) CachedCrop ¶
CachedCrop returns a cached crop rectangle for one analysis.
Parameters:
- start: Seek offset.
- window: Sampling window, already clamped by the caller.
Returns:
- rect: The cached rectangle.
- ok: True when the file had been analyzed and still is that file.
func (Key) CachedPeak ¶
CachedPeak returns a cached PQ luma peak for one analysis.
Parameters:
- start: Seek offset.
- window: Sampling window, already clamped by the caller.
Returns:
- peak: The cached peak.
- ok: True when the file had been analyzed and still is that file.