oggmeta

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 14 Imported by: 1

README

OGGMeta

OGGMeta is a metadata reader and writer for OGG Vorbis and Opus files. It's built in pure go. A lot of research went into understanding the OGG format and vorbis comments. This library provides an interface for audiometa v3 to interact with OGG meta tags.

License

This project is licensed under the MIT License. See the LICENSE file for details.

audiometa v3

mp3meta

mp4meta

flacmeta

Documentation

Index

Constants

View Source
const (
	Vorbis = "vorbis"
	Opus   = "opus"
)
View Source
const (
	HeaderSize         = 27
	MaxSegSize         = 255
	MaxSegSequenceSize = MaxSegSize * 255
	MaxPageSize        = HeaderSize + MaxSegSequenceSize + MaxSegSize
)
View Source
const (
	FlagCOP = 1 << iota // Continuation of packet
	FlagBOS             // Beginning of stream
	FlagEOS             // End of stream
)

Variables

View Source
var (
	Oggs         = [4]byte{'O', 'g', 'g', 'S'}
	VorbisPrefix = []byte("\x03vorbis")
	OpusPrefix   = []byte("OpusTags")
)

Functions

func SaveTags

func SaveTags(tag *OggTag, writer io.Writer) error

Types

type ErrBadSegs

type ErrBadSegs struct{}

func (*ErrBadSegs) Error

func (e *ErrBadSegs) Error() string

type ErrInvalidOggs

type ErrInvalidOggs struct{}

func (*ErrInvalidOggs) Error

func (e *ErrInvalidOggs) Error() string

type OGGDecoder

type OGGDecoder struct {
	Reader    io.ReadSeeker
	TagReader io.ReadSeeker
}

func (*OGGDecoder) Decode

func (dec *OGGDecoder) Decode() (*OGGPage, error)

func (*OGGDecoder) ReadTags

func (dec *OGGDecoder) ReadTags() (*OggTag, error)

type OGGEncoder

type OGGEncoder struct {
	Writer     io.Writer
	Serial     uint32
	PageNumber uint32
}

func (*OGGEncoder) Encode

func (enc *OGGEncoder) Encode(granule int64, packets [][]byte) error

Encode writes a data packet to the ogg stream with a given granule position. Large packets are split across multiple pages with continuation-of-packet flag set. Packets can be empty or nil, resulting in a single segment of size 0.

func (*OGGEncoder) EncodeBOS

func (enc *OGGEncoder) EncodeBOS(granule int64, packets [][]byte) error

EncodeBOS writes a beginning-of-stream packet to the ogg stream with a given granule position. Large packets are split across multiple pages with continuation-of-packet flag set. Packets can be empty or nil, resulting in a single segment of size 0.

func (*OGGEncoder) EncodeEOS

func (enc *OGGEncoder) EncodeEOS(granule int64, packets [][]byte) error

EncodeEOS writes a end-of-stream packet to the ogg stream. Packets can be empty or nil, resulting in a single segment of size 0.

func (*OGGEncoder) Segmentize

func (enc *OGGEncoder) Segmentize(pay segmentizePayload) ([]byte, segmentizePayload, segmentizePayload)

func (*OGGEncoder) WritePackets

func (enc *OGGEncoder) WritePackets(flag byte, granulePosition int64, packets [][]byte) error

type OGGPage

type OGGPage struct {
	Header  OGGPageHeader
	Packets [][]byte
}

type OGGPageHeader

type OGGPageHeader struct {
	Oggs               [4]byte
	Version            byte
	Flags              byte
	GranulePosition    int64
	SerialNumber       uint32
	PageSequenceNumber uint32
	CRC                uint32
	Segments           byte
}

type OggTag

type OggTag struct {
	Album          string
	AlbumArtist    string
	Artist         string
	BPM            string
	Codec          string
	Composer       string
	Copyright      string
	CoverArt       *image.Image
	DiscNumber     string
	DiscTotal      string
	Encoder        string
	Genre          string
	Title          string
	TrackNumber    string
	TrackTotal     string
	UnmappedFields map[string]string
	Vendor         string
	// contains filtered or unexported fields
}

func ReadOGG

func ReadOGG(r io.ReadSeeker) (*OggTag, error)

func (*OggTag) ClearAllTags

func (o *OggTag) ClearAllTags()

func (*OggTag) GetAlbum

func (o *OggTag) GetAlbum() string

func (*OggTag) GetAlbumArtist

func (o *OggTag) GetAlbumArtist() string

func (*OggTag) GetArtist

func (o *OggTag) GetArtist() string

func (*OggTag) GetBPM

func (o *OggTag) GetBPM() int

func (*OggTag) GetComposer

func (o *OggTag) GetComposer() string

func (*OggTag) GetCopyright

func (o *OggTag) GetCopyright() string

func (*OggTag) GetCoverArt

func (o *OggTag) GetCoverArt() *image.Image

func (*OggTag) GetDiscNumber

func (o *OggTag) GetDiscNumber() int

func (*OggTag) GetDiscTotal

func (o *OggTag) GetDiscTotal() int

func (*OggTag) GetEncoder

func (o *OggTag) GetEncoder() string

func (*OggTag) GetGenre

func (o *OggTag) GetGenre() string

func (*OggTag) GetTitle

func (o *OggTag) GetTitle() string

func (*OggTag) GetTrackNumber

func (o *OggTag) GetTrackNumber() int

func (*OggTag) GetTrackTotal

func (o *OggTag) GetTrackTotal() int

func (*OggTag) Save

func (o *OggTag) Save(w io.Writer) error

func (*OggTag) SetAlbum

func (o *OggTag) SetAlbum(album string)

func (*OggTag) SetAlbumArtist

func (o *OggTag) SetAlbumArtist(albumArtist string)

func (*OggTag) SetArtist

func (o *OggTag) SetArtist(artist string)

func (*OggTag) SetBPM

func (o *OggTag) SetBPM(bpm int)

func (*OggTag) SetComposer

func (o *OggTag) SetComposer(composer string)

func (*OggTag) SetCopyright

func (o *OggTag) SetCopyright(copyright string)

func (*OggTag) SetCoverArt

func (o *OggTag) SetCoverArt(coverArt *image.Image)

func (*OggTag) SetDiscNumber

func (o *OggTag) SetDiscNumber(discNumber int)

func (*OggTag) SetDiscTotal

func (o *OggTag) SetDiscTotal(discTotal int)

func (*OggTag) SetEncoder

func (o *OggTag) SetEncoder(encoder string)

func (*OggTag) SetGenre

func (o *OggTag) SetGenre(genre string)

func (*OggTag) SetTitle

func (o *OggTag) SetTitle(title string)

func (*OggTag) SetTrackNumber

func (o *OggTag) SetTrackNumber(trackNumber int)

func (*OggTag) SetTrackTotal

func (o *OggTag) SetTrackTotal(trackTotal int)

Jump to

Keyboard shortcuts

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