Documentation ¶
Index ¶
- Constants
- func ContainSoundData(soundData audio.SoundData) []byte
- func ExtractAudio(data []byte) (soundData audio.SoundData, err error)
- func Write(dest io.Writer, container Container)
- type Container
- type ContainerBuilder
- func (builder *ContainerBuilder) AddEntry(entry Entry) *ContainerBuilder
- func (builder *ContainerBuilder) AudioSampleRate(value uint16) *ContainerBuilder
- func (builder *ContainerBuilder) Build() Container
- func (builder *ContainerBuilder) MediaDuration(value float32) *ContainerBuilder
- func (builder *ContainerBuilder) StartPalette(palette color.Palette) *ContainerBuilder
- func (builder *ContainerBuilder) VideoHeight(value uint16) *ContainerBuilder
- func (builder *ContainerBuilder) VideoWidth(value uint16) *ContainerBuilder
- type DataType
- type Entry
- type HighResVideoHeader
- type LowResVideoHeader
- type MediaDispatcher
- type MediaHandler
- type SubtitleControl
- type SubtitleHeader
Constants ¶
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) )
const ( SubtitleArea = SubtitleControl(0x41455241) SubtitleTextStd = SubtitleControl(0x20445453) SubtitleTextFrn = SubtitleControl(0x204E5246) SubtitleTextGer = SubtitleControl(0x20524547) )
const HighResVideoHeaderSize = 2
HighResVideoHeaderSize is the size, in bytes, of the header structure.
const LowResVideoHeaderSize = 8
LowResVideoHeaderSize is the size, in bytes, of the header structure.
const SubtitleHeaderSize = 16
SubtitleHeaderSize is the size, in bytes, of the header structure
Variables ¶
This section is empty.
Functions ¶
func ContainSoundData ¶
ContainSoundData packs a sound data into a container and encodes it.
func ExtractAudio ¶
ExtractAudio decodes the given data array as a MOVI container and extracts the audio track.
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.
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 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.
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