webm

package
v0.20.22 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package webm provides the WebM multimedia writer.

The package implements block data writer for multi-track WebM container.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultEBMLHeader is the default EBML header used by BlockWriter.
	DefaultEBMLHeader = &EBMLHeader{
		EBMLVersion:        1,
		EBMLReadVersion:    1,
		EBMLMaxIDLength:    4,
		EBMLMaxSizeLength:  8,
		DocType:            "webm",
		DocTypeVersion:     4,
		DocTypeReadVersion: 2,
	}
	// DefaultSegmentInfo is the default Segment.Info used by BlockWriter.
	DefaultSegmentInfo = &Info{
		TimecodeScale: 1000000,
		MuxingApp:     "ebml-go.webm.BlockWriter",
		WritingApp:    "ebml-go.webm.BlockWriter",
	}
	// DefaultBlockInterceptor is the default BlockInterceptor used by BlockWriter.
	DefaultBlockInterceptor = mkvcore.MustBlockInterceptor(mkvcore.NewMultiTrackBlockSorter(mkvcore.WithMaxDelayedPackets(16), mkvcore.WithSortRule(mkvcore.BlockSorterDropOutdated)))
)

Functions

This section is empty.

Types

type Audio

type Audio struct {
	SamplingFrequency       float64 `ebml:"SamplingFrequency"`
	Channels                uint64  `ebml:"Channels"`
	OutputSamplingFrequency float64 `ebml:"OutputSamplingFrequency,omitempty"`
	BitDepth                uint64  `ebml:"BitDepth,omitempty"`
}

Audio represents Audio element struct.

type BlockCloser

type BlockCloser interface {
	mkvcore.BlockCloser
}

BlockCloser is a WebM closer interface.

type BlockGroup

type BlockGroup struct {
	BlockDuration  uint64     `ebml:"BlockDuration,omitempty"`
	ReferenceBlock int64      `ebml:"ReferenceBlock,omitempty"`
	Block          ebml.Block `ebml:"Block"`
}

BlockGroup represents BlockGroup element struct.

type BlockReadCloser

type BlockReadCloser interface {
	mkvcore.BlockReadCloser
}

BlockReadCloser groups Reader and Closer.

type BlockReader

type BlockReader interface {
	mkvcore.BlockReader
}

BlockReader is a WebM block reader interface.

type BlockWriteCloser

type BlockWriteCloser interface {
	mkvcore.BlockWriteCloser
}

BlockWriteCloser groups Writer and Closer.

func NewSimpleBlockWriter

func NewSimpleBlockWriter(w0 io.WriteCloser, tracks []*TrackEntry, opts ...mkvcore.BlockWriterOption) ([]BlockWriteCloser, error)

NewSimpleBlockWriter creates BlockWriteCloser for each track specified as tracks argument. Blocks will be written to WebM as EBML SimpleBlocks. Resultant WebM is written to given io.WriteCloser and will be closed automatically; don't close it by yourself. Frames written to each track must be sorted by their timestamp.

type BlockWriter

type BlockWriter interface {
	mkvcore.BlockWriter
}

BlockWriter is a WebM block writer interface.

type Cluster

type Cluster struct {
	Timecode    uint64       `ebml:"Timecode"`
	PrevSize    uint64       `ebml:"PrevSize,omitempty"`
	BlockGroup  []BlockGroup `ebml:"BlockGroup"`
	SimpleBlock []ebml.Block `ebml:"SimpleBlock"`
}

Cluster represents Cluster element struct.

type CuePoint

type CuePoint struct {
	CueTime           uint64             `ebml:"CueTime"`
	CueTrackPositions []CueTrackPosition `ebml:"CueTrackPositions"`
}

CuePoint represents CuePoint element struct.

type CueTrackPosition

type CueTrackPosition struct {
	CueTrack           uint64 `ebml:"CueTrack"`
	CueClusterPosition uint64 `ebml:"CueClusterPosition"`
	CueBlockNumber     uint64 `ebml:"CueBlockNumber,omitempty"`
}

CueTrackPosition represents CueTrackPosition element struct.

type Cues

type Cues struct {
	CuePoint []CuePoint `ebml:"CuePoint"`
}

Cues represents Cues element struct.

type EBMLHeader

type EBMLHeader struct {
	EBMLVersion        uint64 `ebml:"EBMLVersion"`
	EBMLReadVersion    uint64 `ebml:"EBMLReadVersion"`
	EBMLMaxIDLength    uint64 `ebml:"EBMLMaxIDLength"`
	EBMLMaxSizeLength  uint64 `ebml:"EBMLMaxSizeLength"`
	DocType            string `ebml:"EBMLDocType"`
	DocTypeVersion     uint64 `ebml:"EBMLDocTypeVersion"`
	DocTypeReadVersion uint64 `ebml:"EBMLDocTypeReadVersion"`
}

EBMLHeader represents EBML header struct.

type FrameWriter deprecated

type FrameWriter struct {
	mkvcore.BlockWriteCloser
}

FrameWriter is a backward compatibility wrapper of BlockWriteCloser.

Deprecated: This is exposed to keep compatibility with the old version. Use BlockWriteCloser interface instead.

func NewSimpleWriter deprecated

func NewSimpleWriter(w0 io.WriteCloser, tracks []*TrackEntry, opts ...mkvcore.BlockWriterOption) ([]*FrameWriter, error)

NewSimpleWriter creates BlockWriteCloser for each track specified as tracks argument. Blocks will be written to WebM as EBML SimpleBlocks. Resultant WebM is written to given io.WriteCloser. io.WriteCloser will be closed automatically; don't close it by yourself.

Deprecated: This is exposed to keep compatibility with the old version. Use NewSimpleBlockWriter instead.

type Info

type Info struct {
	TimecodeScale uint64    `ebml:"TimecodeScale"`
	MuxingApp     string    `ebml:"MuxingApp,omitempty"`
	WritingApp    string    `ebml:"WritingApp,omitempty"`
	Duration      float64   `ebml:"Duration,omitempty"`
	DateUTC       time.Time `ebml:"DateUTC,omitempty"`
}

Info represents Info element struct.

func (*Info) GetDuration

func (c *Info) GetDuration() time.Duration

func (*Info) SetDateUTC

func (c *Info) SetDateUTC(date time.Time)

func (*Info) SetDuration

func (c *Info) SetDuration(duration float64)

type Seek

type Seek struct {
	SeekID       []byte `ebml:"SeekID"`
	SeekPosition uint64 `ebml:"SeekPosition"`
}

Seek represents Seek element struct.

type SeekHead

type SeekHead struct {
	Seek []Seek `ebml:"Seek"`
}

SeekHead represents SeekHead element struct.

type Segment

type Segment struct {
	SeekHead *SeekHead `ebml:"SeekHead"`
	Info     Info      `ebml:"Info"`
	Tracks   Tracks    `ebml:"Tracks"`
	Cluster  []Cluster `ebml:"Cluster"`
	Cues     *Cues     `ebml:"Cues"`
}

Segment represents Segment element struct.

type SegmentStream

type SegmentStream struct {
	SeekHead *SeekHead `ebml:"SeekHead"`
	Info     Info      `ebml:"Info"`
	Tracks   Tracks    `ebml:"Tracks"`
	Cluster  []Cluster `ebml:"Cluster,size=unknown"`
}

SegmentStream represents Segment element struct for streaming.

type TrackEntry

type TrackEntry struct {
	Name            string         `ebml:"Name,omitempty"`
	TrackNumber     uint64         `ebml:"TrackNumber"`
	TrackUID        uint64         `ebml:"TrackUID"`
	CodecID         core.CodecType `ebml:"CodecID"`
	CodecDelay      uint64         `ebml:"CodecDelay,omitempty"`
	TrackType       core.TrackType `ebml:"TrackType"`
	DefaultDuration uint64         `ebml:"DefaultDuration,omitempty"`
	SeekPreRoll     uint64         `ebml:"SeekPreRoll,omitempty"`
	Audio           *Audio         `ebml:"Audio"`
	Video           *Video         `ebml:"Video"`
	CodecPrivate    []byte         `ebml:"CodecPrivate,omitempty"`
	Void            []byte         `ebml:"Void,omitempty"`
}

TrackEntry represents TrackEntry element struct.

func (*TrackEntry) SetAudioSamplingFrequency

func (c *TrackEntry) SetAudioSamplingFrequency(samplingFrequency float64)

func (*TrackEntry) SetCodecPrivate added in v0.20.12

func (c *TrackEntry) SetCodecPrivate(codecPrivate []byte) error

type Tracks

type Tracks struct {
	TrackEntry []TrackEntry `ebml:"TrackEntry"`
}

Tracks represents Tracks element struct.

type Video

type Video struct {
	PixelWidth  uint64 `ebml:"PixelWidth"`
	PixelHeight uint64 `ebml:"PixelHeight"`
	Void        []byte `ebml:"Void,omitempty"`
}

Video represents Video element struct.

func (*Video) Set added in v0.20.14

func (v *Video) Set(w uint64, h uint64)

Jump to

Keyboard shortcuts

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