Documentation
¶
Overview ¶
Package avi reads RIFF AVI files, including OpenDML files larger than 1 GB.
Index ¶
- Variables
- type BitmapInfo
- type File
- type Sample
- type Stream
- func (s *Stream) Info(i int) Sample
- func (s *Stream) Len() int
- func (s *Stream) ReadSample(i int, buf []byte) (Sample, error)
- func (s *Stream) Sample(i int) (Sample, error)
- func (s *Stream) SampleData(i int, buf []byte) (data, config []byte, err error)
- func (s *Stream) SampleTime(i int) (time.Duration, bool)
- func (s *Stream) Samples() iter.Seq2[Sample, error]
- func (s *Stream) Time(ticks int64) time.Duration
- type WaveFormat
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalid reports a malformed file. ErrInvalid = errors.New("avi: invalid data") // ErrUnsupported reports a well-formed file this package does not read. ErrUnsupported = errors.New("avi: unsupported") )
Functions ¶
This section is empty.
Types ¶
type BitmapInfo ¶
type BitmapInfo struct {
Width, Height int
BitCount int
// Compression is the four-character code of the codec.
Compression string
// Extra is the codec data after the header, such as an MPEG-4 VOL.
Extra []byte
}
BitmapInfo is the format of a video stream.
func ParseBitmapInfo ¶
func ParseBitmapInfo(b []byte) (*BitmapInfo, error)
ParseBitmapInfo parses a BITMAPINFOHEADER, such as a Matroska VfW codec private.
type File ¶
type File struct {
// MicroSecPerFrame, Flags, Width and Height are from the main header.
MicroSecPerFrame uint32
Flags uint32
Width, Height int
// TotalFrames is the OpenDML frame count when present, else the main header's.
TotalFrames uint32
Streams []*Stream
// contains filtered or unexported fields
}
File is an opened AVI file.
type Sample ¶
type Sample struct {
// Data is nil when the sample was looked up by [Stream.Info].
Data []byte
// Ticks is the sample's start in the stream's Scale/Rate units, Start included.
Ticks int64
// Key reports a keyframe; every chunk is key when the file has no index.
Key bool
// Offset and Size locate the chunk data in the file.
Offset int64
Size int
}
Sample is one chunk of a stream.
type Stream ¶
type Stream struct {
// Type is "vids", "auds", "txts" or "mids", and Handler the stream header's codec code.
Type, Handler string
// Scale, Rate, Start, Length and SampleSize are from the stream header; Rate/Scale is ticks per second.
Scale, Rate uint32
Start, Length uint32
SampleSize uint32
// Name is the stream name, empty when there is none.
Name string
// Video is set for a video stream, Audio for an audio stream.
Video *BitmapInfo
Audio *WaveFormat
// AspectX and AspectY are the display aspect from the OpenDML video properties, 0 when absent.
AspectX, AspectY int
// contains filtered or unexported fields
}
Stream is one stream of a file and the index of its chunks.
func (*Stream) ReadSample ¶
ReadSample is sample i, its data read into buf when buf is large enough.
func (*Stream) SampleData ¶
SampleData is the data of sample i, read into buf when it fits, and the codec data of the stream.
func (*Stream) SampleTime ¶
SampleTime is the presentation time of sample i and whether it is a keyframe.
type WaveFormat ¶
type WaveFormat struct {
// Tag is the format tag, taken from the subformat for WAVEFORMATEXTENSIBLE.
Tag uint16
Channels int
SampleRate int
AvgBytesPerSec int
BlockAlign int
BitsPerSample int
// Extra is the data after the cbSize field.
Extra []byte
}
WaveFormat is the format of an audio stream.
func ParseWaveFormat ¶
func ParseWaveFormat(b []byte) (*WaveFormat, error)
ParseWaveFormat parses a WAVEFORMATEX, such as a Matroska ACM codec private.