movi

package
v0.0.0-...-e78e2ff Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: BSD-3-Clause Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (

	// LowResVideo for low resolution (low compression) video
	LowResVideo = DataType(0x21)
	// HighResVideo for high resolution (high compression) video
	HighResVideo = DataType(0x79)
	// Audio marks an audio entry.
	Audio = DataType(2)
	// Subtitle control
	Subtitle = DataType(3)
	// Palette data
	Palette = DataType(4)
	// PaletteReset is a zero-byte entry immediately before a Palette entry.
	PaletteReset = DataType(0x4C)
	// PaletteLookupList for high compression video.
	PaletteLookupList = DataType(5)
	// ControlDictionary for high compression video
	ControlDictionary = DataType(0x0D)
)
View Source
const (
	SubtitleArea    = SubtitleControl(0x41455241)
	SubtitleTextStd = SubtitleControl(0x20445453)
	SubtitleTextFrn = SubtitleControl(0x204E5246)
	SubtitleTextGer = SubtitleControl(0x20524547)
)
View Source
const HighResVideoHeaderSize = 2

HighResVideoHeaderSize is the size, in bytes, of the header structure.

View Source
const LowResVideoHeaderSize = 8

LowResVideoHeaderSize is the size, in bytes, of the header structure.

View Source
const SubtitleHeaderSize = 16

SubtitleHeaderSize is the size, in bytes, of the header structure

Variables

This section is empty.

Functions

func ContainSoundData

func ContainSoundData(soundData audio.SoundData) []byte

ContainSoundData packs a sound data into a container and encodes it.

func ExtractAudio

func ExtractAudio(data []byte) (soundData audio.SoundData, err error)

ExtractAudio decodes the given data array as a MOVI container and extracts the audio track.

func Write

func Write(dest io.Writer, container Container)

Write encodes the provided container into the given writer.

Types

type Container

type Container interface {
	// MediaDuration returns the duration of the media in seconds.
	MediaDuration() float32

	// VideoWidth returns the width of a video in pixel.
	VideoWidth() uint16
	// VideoHeight returns the height of a video in pixel.
	VideoHeight() uint16
	// StartPalette returns the initial pallete of a video.
	StartPalette() color.Palette

	// AudioSampleRate returns the sample frequency used for audio entries.
	AudioSampleRate() uint16

	// EntryCount returns the number of available entries.
	EntryCount() int
	// Entry returns the entry for given index.
	Entry(index int) Entry
}

Container wraps the information and data of a MOVI container.

func Read

func Read(source io.ReadSeeker) (container Container, err error)

Read tries to extract a MOVI container from the provided reader. On success the position of the reader is past the last data entry. On failure the position of the reader is undefined.

type ContainerBuilder

type ContainerBuilder struct {
	// contains filtered or unexported fields
}

ContainerBuilder is the builder implementation for a Container.

func NewContainerBuilder

func NewContainerBuilder() *ContainerBuilder

NewContainerBuilder returns a new builder for creating a new container.

func (*ContainerBuilder) AddEntry

func (builder *ContainerBuilder) AddEntry(entry Entry) *ContainerBuilder

AddEntry adds the given entry to the list.

func (*ContainerBuilder) AudioSampleRate

func (builder *ContainerBuilder) AudioSampleRate(value uint16) *ContainerBuilder

AudioSampleRate sets the video width for the new container.

func (*ContainerBuilder) Build

func (builder *ContainerBuilder) Build() Container

Build returns the immutable instance of a new container.

func (*ContainerBuilder) MediaDuration

func (builder *ContainerBuilder) MediaDuration(value float32) *ContainerBuilder

MediaDuration sets the duration for the new container in seconds.

func (*ContainerBuilder) StartPalette

func (builder *ContainerBuilder) StartPalette(palette color.Palette) *ContainerBuilder

StartPalette sets the initial palette of the new container

func (*ContainerBuilder) VideoHeight

func (builder *ContainerBuilder) VideoHeight(value uint16) *ContainerBuilder

VideoHeight sets the video height for the new container.

func (*ContainerBuilder) VideoWidth

func (builder *ContainerBuilder) VideoWidth(value uint16) *ContainerBuilder

VideoWidth sets the video width for the new container.

type DataType

type DataType byte

DataType identifies entries

type Entry

type Entry interface {
	// Timestamp marks the beginning time of the entry, in seconds.
	Timestamp() float32
	// Type describes the content type of the data.
	Type() DataType
	// Data returns the raw bytes of the entry.
	Data() []byte
}

Entry describes a block from a MOVI container.

func NewMemoryEntry

func NewMemoryEntry(timestamp float32, dataType DataType, data []byte) Entry

NewMemoryEntry returns an Entry instance that has the properties in memory.

type HighResVideoHeader

type HighResVideoHeader struct {
	PixelDataOffset uint16
}

HighResVideoHeader is for video entries with high resolution.

type LowResVideoHeader

type LowResVideoHeader struct {
	BoundingBox [4]uint16
}

LowResVideoHeader is for video entries with low resolution

type MediaDispatcher

type MediaDispatcher struct {
	// contains filtered or unexported fields
}

MediaDispatcher iterates through the entries of a container and provides resulting media to a handler. The dispatcher handles intermediate container entries to create consumable media.

func NewMediaDispatcher

func NewMediaDispatcher(container Container, handler MediaHandler) *MediaDispatcher

NewMediaDispatcher returns a new instance of a dispatcher reading the provided container.

func (*MediaDispatcher) DispatchNext

func (dispatcher *MediaDispatcher) DispatchNext() (result bool, err error)

DispatchNext processes the next entries from the container to call the handler. Returns false if the dispatcher reached the end of the container.

type MediaHandler

type MediaHandler interface {
	// OnAudio is called for an audio entry.
	OnAudio(timestamp float32, samples []byte)
	// OnSubtitle is called for a subtitle entry.
	OnSubtitle(timestamp float32, control SubtitleControl, text string)
	// OnVideo is called for a video entry.
	OnVideo(timestamp float32, frame *image.Paletted)
}

MediaHandler is called from a MediaDispatcher on various media entries.

type SubtitleControl

type SubtitleControl uint32

SubtitleControl specifies how to interpret a subtitle entry.

func (SubtitleControl) String

func (ctrl SubtitleControl) String() string

String returns the string presentation of the control value.

type SubtitleHeader

type SubtitleHeader struct {
	// Control specifies how to interpret the string content
	Control SubtitleControl

	Unknown0004 byte
	Unknown0005 [11]byte
}

SubtitleHeader is the header structure of a subtitle data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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