ffmsindex

package
v5.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2019 License: BSD-2-Clause-Views Imports: 4 Imported by: 0

Documentation

Overview

Package ffmsindex provides a native Go library for parsing FFMS2 Indexes, for versions post-2.23.

Index

Constants

View Source
const (
	TypeAudio = TrackType(1)
	TypeVideo = TrackType(0)
)

Track types

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {
	PTS         int64
	OriginalPTS int64
	FilePos     int64
	SampleStart int64
	SampleCount uint32
	OriginalPos uint64
	FrameType   int
	RepeatPict  int32
	KeyFrame    bool
	Hidden      bool
}

Frame contains all info about a particular frame or sample.

type Header struct {
	ID      uint32
	Version struct {
		Major uint8
		Minor uint8
		Micro uint8
		Bump  uint8
	}
	IndexVersion  uint16
	Tracks        uint32
	ErrorHandling uint32
	AVUtilVersion struct {
		Major uint8
		Minor uint8
		Micro uint8
	}
	AVFormatVersion struct {
		Major uint8
		Minor uint8
		Micro uint8
	}
	AVCodecVersion struct {
		Major uint8
		Minor uint8
		Micro uint8
	}
	SWScaleVersion struct {
		Major uint8
		Minor uint8
		Micro uint8
	}
	FileSize int64
	Digest   [20]byte
}

Header is the FFIndex header. It contains info on what versions of various libraries the index was generated with, and some other misc info about how it was generated.

type Index

type Index struct {
	Header *Header
	Tracks []*Track
}

Index contains all info from the parsed index.

func ReadIndex

func ReadIndex(r io.Reader) (*Index, error)

ReadIndex parses the ffindex from the reader, and returns information on all tracks and headers. Unlike FFMS2 itself, it will not fail if the libav* library versions do not match, since it is intended to extract information only.

type Track

type Track struct {
	TrackType TrackType
	TimeBase  struct {
		Num int64
		Den int64
	}
	LastDuration int64
	MaxBFrames   int32
	UseDTS       bool
	HasTS        bool
	Frames       []Frame
	// contains filtered or unexported fields
}

Track contains all info about a particular track, and all of its frames.

func (*Track) GetKeyframeIndices added in v5.1.0

func (t *Track) GetKeyframeIndices() []uint

GetKeyframeIndicies gets a list of indicies that can be used in a given Track's frame slice. This differs from GetKeyframes in that it takes into account all frames, and not only visible frames. GetKeyframes would be more suitable, to, for example, use for seeking with FFMS2's API, or measuring keyframe distances.

func (*Track) GetKeyframes

func (t *Track) GetKeyframes() []uint

GetKeyframes gets a list of visible frame numbers which are keyframes. This frame number will differ from the frame number in the Frames slice, since some codecs, such as VP8, have hidden frames. This function takes those into account when calculating the frame numbers.

func (*Track) GetTimestamps

func (t *Track) GetTimestamps() []int64

GetTimestamps returns a list of timestamps for visible frames. The number of timestamps may differ from the length of the Frames slice, since some codecs, such as VP8, have hidden frames. This function takes those into account.

type TrackType

type TrackType uint8

TrackType is the type of the track

func (TrackType) MarshalJSON

func (t TrackType) MarshalJSON() ([]byte, error)

MarshalJSON is a standard implementation of JSON marshalling for the TrackType type.

func (TrackType) String

func (t TrackType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL