Documentation
¶
Overview ¶
file_io_handlers.go provides local-file implementations of the avpipe I/O interfaces (goavpipe.InputOpener / OutputOpener) for use in tests.
Special test features:
Error injection: ErrorOnOpen / ErrorOnRead on FileInputOpener force deterministic I/O failures
Stat collection: when a shared IOStats is attached, the handlers accumulate transcoding stats (frames read/written, keyframe PTS, encoding stats) reported by the avpipe xc stats callbacks.
Index ¶
Constants ¶
const DefaultABRSegmentsPerPart = 15
DefaultABRSegmentsPerPart is the default number of ABR segments per mez part.
Variables ¶
This section is empty.
Functions ¶
func InitSegmentsMatch ¶
func InitSegmentsMatch(a, b *InitSegmentInfo) error
InitSegmentsMatch compares two init segments for codec compatibility. It checks codec type, dimensions, timescale, and SPS/PPS/VPS byte equality. Returns nil if they match, or an error describing the first mismatch.
Types ¶
type ABRSegmentResult ¶
type ABRSegmentResult struct {
Errors []string
FrameCount int
FragCount int
Timescale uint32
SampleDur uint64 // most common sample duration
DtsStart uint64
DtsEnd uint64
DtsProblems int // non-consecutive DTS count
DurProblems int // unequal duration count
SeqFirst uint32 // first mfhd sequence number
SeqLast uint32 // last mfhd sequence number
}
ABRSegmentResult holds the results of ABR segment validation.
func ValidateABRSegment ¶
func ValidateABRSegment(filename string) (*ABRSegmentResult, error)
ValidateABRSegment validates a DASH/HLS segment (m4s file). Checks:
- consecutive DTS (each sample DTS = previous DTS + duration)
- equal frame durations across all samples
- reports frame and fragment counts for the caller to check
func (*ABRSegmentResult) AllErrors ¶
func (r *ABRSegmentResult) AllErrors() error
AllErrors returns a combined error with all issues, or nil if valid.
func (*ABRSegmentResult) Valid ¶
func (r *ABRSegmentResult) Valid() bool
Valid returns true if no errors were found.
type ContinuityProblem ¶
type ContinuityProblem struct {
SampleIndex int
Field string // "PTS" or "DTS"
Expected uint64
Actual uint64
}
ContinuityProblem records a PTS/DTS continuity issue at a specific sample.
type FileInputOpener ¶
type FileInputOpener struct {
URL string
ErrorOnOpen bool // return fs.ErrPermission from Open
ErrorOnRead bool // return io.ErrNoProgress from Read
Stats *IOStats // optional stats collector
}
FileInputOpener implements goavpipe.InputOpener for local files.
func (*FileInputOpener) Open ¶
func (fio *FileInputOpener) Open(_ int64, url string) (goavpipe.InputHandler, error)
type FileOutputOpener ¶
FileOutputOpener implements goavpipe.OutputOpener for local files.
type FramesPerFragment ¶
type FramesPerFragment int
FramesPerFragment defines how many frames are stored per fragment in a mez part.
const (
OneFramePerFragment FramesPerFragment = 1
)
type IOStats ¶
type IOStats struct {
AudioFramesRead uint64
VideoFramesRead uint64
FirstKeyFramePTS uint64
EncodingAudioFrameStats avpipe.EncodingFrameStats
EncodingVideoFrameStats avpipe.EncodingFrameStats
}
IOStats collects stats from the avpipe C engine during transcoding. Attach to FileInputOpener and/or FileOutputOpener to capture stats.
type InitSegmentInfo ¶
type InitSegmentInfo struct {
Codec string
Width int
Height int
Timescale uint32
SPS [][]byte // Sequence Parameter Sets
PPS [][]byte // Picture Parameter Sets
VPS [][]byte // Video Parameter Sets (HEVC only)
}
InitSegmentInfo holds parsed properties from a DASH/HLS init segment.
func ValidateInitSegment ¶
func ValidateInitSegment(filename string) (*InitSegmentInfo, error)
ValidateInitSegment parses an init segment and extracts stream properties including SPS, PPS, and VPS (for MVHEVC).
type MezPartParams ¶
type MezPartParams struct {
// FrameRate is the video frame rate as a rational number (e.g. 50/1 or 60000/1001).
FrameRate *big.Rat
// ABRVideoSegDuration is the duration of each ABR video segment in seconds
// (e.g. 2.0 for 50fps, or 2.002 for 59.94fps).
ABRVideoSegDuration *big.Rat
// ABRAudioSegDuration is the duration of each ABR audio segment in seconds.
ABRAudioSegDuration *big.Rat
// ABRSegmentsPerPart is the number of ABR segments per mez part (default 15).
ABRSegmentsPerPart int
// FramesPerFrag specifies how many frames are stored per fragment.
FramesPerFrag FramesPerFragment
// StartPTS is the expected starting PTS of the part (typically 0).
StartPTS uint64
}
MezPartParams defines the expected properties of a mezzanine part for validation.
func (*MezPartParams) ExpectedFrameCount ¶
func (p *MezPartParams) ExpectedFrameCount() int
ExpectedFrameCount returns the total number of frames expected in a mez part.
type MezPartResult ¶
type MezPartResult struct {
// Errors collects all validation errors.
Errors []string
// ContinuityProblems records specific PTS/DTS continuity issues.
ContinuityProblems []ContinuityProblem
// MissingKeyFrames is the number of expected key frames that were not found.
MissingKeyFrames int
// FrameCount is the actual number of frames/samples found.
FrameCount int
// FragmentCount is the actual number of fragments found.
FragmentCount int
// Timescale is the media timescale extracted from the file.
Timescale uint32
// SampleDuration is the expected sample duration in timescale units.
SampleDuration uint64
}
MezPartResult holds the results of mez part validation.
func ValidateMezPart ¶
func ValidateMezPart(filename string, params *MezPartParams) (*MezPartResult, error)
ValidateMezPart validates a mezzanine part file against expected parameters.
func (*MezPartResult) AllErrors ¶
func (r *MezPartResult) AllErrors() error
AllErrors returns a combined error with all issues, or nil if valid.
func (*MezPartResult) Valid ¶
func (r *MezPartResult) Valid() bool
Valid returns true if no errors were found.