Documentation
¶
Overview ¶
This is a package for reading, writing and inspecting media files. In order to operate on media, call NewManager() and then use the manager functions to determine capabilities and manage media files and devices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NativeEndian binary.ByteOrder
NativeEndian is the ByteOrder of the current system.
Functions ¶
This section is empty.
Types ¶
type AudioParameters ¶ added in v1.6.3
type AudioParameters interface { // Return the channel layout ChannelLayout() string // Return the sample format SampleFormat() string // Return the sample rate (Hz) Samplerate() int }
Audio parameters for encoding or decoding audio data.
type Decoder ¶ added in v1.6.1
type Decoder interface { // Demultiplex media into packets. Pass a packet to a decoder function. // Stop when the context is cancelled or the end of the media stream is // reached. Demux(context.Context, DecoderFunc) error // Decode media into frames, and resample or resize the frame. // Stop when the context is cancelled or the end of the media stream is // reached. Decode(context.Context, FrameFunc) error }
Decoder represents a demuliplexer and decoder for a media stream. You can call either Demux or Decode to process the media stream, but not both.
type DecoderFunc ¶ added in v1.6.1
DecoderFunc is a function that decodes a packet. Return io.EOF if you want to stop processing the packets early.
type DecoderMapFunc ¶ added in v1.6.3
type DecoderMapFunc func(Stream) (Parameters, error)
Return parameters if a the stream should be decoded and either resampled or resized. Return nil if you want to ignore the stream, or pass identical stream parameters (stream.Parameters()) if you want to copy the stream without any changes.
type Device ¶ added in v1.6.3
type Device interface { // Device name, format depends on the device Name() string // Description of the device Description() string // Flags indicating the type INPUT or OUTPUT, AUDIO or VIDEO Type() MediaType // Whether this is the default device Default() bool }
Device represents a device for input or output of media streams. TODO
type Format ¶ added in v1.6.3
type Format interface { // Name(s) of the format Name() []string // Description of the format Description() string // Extensions associated with the format, if a stream. Each extension // should have a preceeding period (ie, ".mp4") Extensions() []string // MimeTypes associated with the format MimeTypes() []string // Flags indicating the type. INPUT for a demuxer or source, OUTPUT for a muxer or // sink, DEVICE for a device, FILE for a file. Plus AUDIO, VIDEO, DATA, SUBTITLE. Type() MediaType }
Format represents a container format for input or output of media streams. Use the manager object to get a list of supported formats.
type Frame ¶ added in v1.5.1
type Frame interface{}
Frame represents a frame of audio or picture data. Currently this is quite opaque - should allow access to the audio sample data, or the individual pixel data!
type FrameFunc ¶ added in v1.6.1
FrameFunc is a function that processes a frame of audio or video data. Return io.EOF if you want to stop processing the frames early.
type Manager ¶ added in v1.5.1
type Manager interface { // Open a media file or device for reading, from a path or url. // If a format is specified, then the format will be used to open // the file. Close the media object when done. Open(string, Format, ...string) (Media, error) // Open a media stream for reading. If a format is // specified, then the format will be used to open the file. Close the // media object when done. It is the responsibility of the caller to // also close the reader when done. Read(io.Reader, Format, ...string) (Media, error) // Create a media file or device for writing, from a path. If a format is // specified, then the format will be used to create the file. Close // the media object when done. // TODO Create(string, Format) (Media, error) // Create a media stream for writing. If a format is // specified, then the format will be used to create the file. // Close the media object when done. It is the responsibility of the caller to // also close the writer when done. // TODO Write(io.Writer, Format) (Media, error) // Return supported input formats which match any filter, which can be // a name, extension (with preceeding period) or mimetype. The MediaType // can be NONE (for any) or combinations of DEVICE and STREAM. InputFormats(MediaType, ...string) []Format // Return supported output formats which match any filter, which can be // a name, extension (with preceeding period) or mimetype. The MediaType // can be NONE (for any) or combinations of DEVICE and STREAM. OutputFormats(MediaType, ...string) []Format // Return supported input devices for a given format name // Not all devices may be supported on all platforms or listed // if the device does not support enumeration. InputDevices(string) []Device // Return supported output devices for a given format name // Not all devices may be supported on all platforms or listed // if the device does not support enumeration. OutputDevices(string) []Device // Return all supported channel layouts ChannelLayouts() []Metadata // Return all supported sample formats SampleFormats() []Metadata // Return all supported pixel formats PixelFormats() []Metadata // Return audio parameters for encoding // ChannelLayout, SampleFormat, Samplerate AudioParameters(string, string, int) (AudioParameters, error) // Return video parameters for encoding // Width, Height, PixelFormat, Framerate VideoParameters(int, int, string, float64) (VideoParameters, error) // Return version information for the media manager as a set of // metadata Version() []Metadata }
Manager represents a manager for media formats and devices. Create a new manager object using the NewManager function.
func NewManager ¶ added in v1.6.2
func NewManager() Manager
type Media ¶
type Media interface { io.Closer // Return a decoding context for the media stream, and // map the streams to decoders. If no function is provided // (ie, the argument is nil) then all streams are demultiplexed. Decoder(DecoderMapFunc) (Decoder, error) // Return INPUT for a demuxer or source, OUTPUT for a muxer or // sink, DEVICE for a device, FILE for a file or stream. Type() MediaType // Return the metadata for the media. Metadata() []Metadata }
Media represents a media stream, which can be input or output. A new media object is created using the Manager object
type MediaType ¶ added in v1.6.1
type MediaType uint32
Media type flags
const ( NONE MediaType = 0 UNKNOWN MediaType = (1 << iota) // Usually treated as DATA VIDEO // Video stream AUDIO // Audio stream DATA // Opaque data information usually continuous SUBTITLE // Subtitle stream INPUT // Demuxer OUTPUT // Muxer FILE // File or byte stream DEVICE // Device rather than stream // Set minimum and maximum values MIN = UNKNOWN MAX = DEVICE // Convenience values ANY = NONE )
func (MediaType) FlagString ¶ added in v1.6.3
func (MediaType) MarshalJSON ¶ added in v1.6.3
type Metadata ¶ added in v1.5.1
type Metadata interface{}
Metadata represents a metadata entry for a media stream. Currently this is quite opaque!
type Packet ¶ added in v1.5.1
type Packet interface{}
Packet represents a packet of demultiplexed data. Currently this is quite opaque!
type Parameters ¶ added in v1.6.3
type Parameters interface { AudioParameters VideoParameters // Return the media type (AUDIO, VIDEO, SUBTITLE, DATA) Type() MediaType }
Parameters represents a set of parameters for encoding
type Stream ¶ added in v1.5.1
type Stream interface { // Return AUDIO, VIDEO, SUBTITLE or DATA Type() MediaType // Return the stream parameters Parameters() Parameters }
Stream represents a audio, video, subtitle or data stream within a media file
type VideoParameters ¶ added in v1.6.3
type VideoParameters interface { // Return the width of the video frame Width() int // Return the height of the video frame Height() int // Return the pixel format PixelFormat() string // Return the frame rate (fps) Framerate() float64 }
Video parameters for encoding or decoding video data.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Media services for golang, including bindings for ffmpeg, command line application
|
Media services for golang, including bindings for ffmpeg, command line application |
extractartwork
An example of extracting artwork from media files.
|
An example of extracting artwork from media files. |
fingerprint
An example of fingerprinting audio and recognizing the any music tracks within the audio.
|
An example of fingerprinting audio and recognizing the any music tracks within the audio. |
media
Package media provides media open, close and conversion support
|
Package media provides media open, close and conversion support |
pkg/_old/_media
Package media provides high-level media services for multiplexing, extracting and transcoding audio and video.
|
Package media provides high-level media services for multiplexing, extracting and transcoding audio and video. |
sys/_ffmpeg
Package ffmpeg provides low-level ffmpeg for go
|
Package ffmpeg provides low-level ffmpeg for go |
transcode
An example of extracting frames from a video.
|
An example of extracting frames from a video. |
cmd
|
|
pkg
|
|
chromaprint
chromaprint provides bindings to the Chromaprint library, which is a library for extracting audio fingerprints.
|
chromaprint provides bindings to the Chromaprint library, which is a library for extracting audio fingerprints. |
file
Package file provides file system support, including file system walking
|
Package file provides file system support, including file system walking |
sys
|
|
chromaprint
This package provides chromaprint audio fingerprinting bindings
|
This package provides chromaprint audio fingerprinting bindings |
dvb
DVB (Digital Video Broadcasting) bindings for Go
|
DVB (Digital Video Broadcasting) bindings for Go |
ffmpeg51
Package ffmpeg provides low-level ffmpeg for go
|
Package ffmpeg provides low-level ffmpeg for go |
ffmpeg61
The low-level ffmpeg bindings for ffmpeg version 6.1.
|
The low-level ffmpeg bindings for ffmpeg version 6.1. |