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 ¶
const ( MetaArtwork = "artwork" // Metadata key for artwork, sets the value as []byte MetaDuration = "duration" // Metadata key for duration, sets the value as float64 (seconds) )
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 Codec ¶ added in v1.5.1
type Codec interface { // Return the codec name Name() string // Return the codec description Description() string // Return the codec type (AUDIO, VIDEO, SUBTITLE, DATA, INPUT, OUTPUT) Type() MediaType }
Codec represents a codec for encoding or decoding media streams.
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.
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 { Parameters // Number of samples in the frame, for an audio frame. NumSamples() int // Return stride for each plane, for a video frame. Stride(int) int // Return a frame plane as a byte slice. Bytes(int) []byte // Return a frame plane as int16 slice Int16(int) []int16 // Return the presentation timestamp for the frame or // a negative number if not set Time() time.Duration // Return a frame as an image, which supports the following // pixel formats: AV_PIX_FMT_GRAY8, AV_PIX_FMT_RGBA, // AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P Image() (image.Image, error) }
Frame represents a frame of audio or video 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 LogFunc ¶ added in v1.6.4
type LogFunc func(string)
Logging function which is used to log messages
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 or else // the format is guessed from the path. If no parameters are provided, // then the default parameters for the format are used. Create(string, Format, []Metadata, ...Parameters) (Media, error) // Create a media stream for writing. The format will be used to // determine the formar type and one or more CodecParameters used to // create the streams. If no parameters are provided, then the // default parameters for the format are used. It is the responsibility // of the caller to also close the writer when done. Write(io.Writer, Format, []Metadata, ...Parameters) (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 devices for a given format. // Not all devices may be supported on all platforms or listed // if the device does not support enumeration. Devices(Format) []Device // Return all supported channel layouts ChannelLayouts() []Metadata // Return all supported sample formats SampleFormats() []Metadata // Return all supported pixel formats PixelFormats() []Metadata // Return all supported codecs Codecs() []Metadata // Return audio parameters for encoding // ChannelLayout, SampleFormat, Samplerate AudioParameters(string, string, int) (Parameters, error) // Return video parameters for encoding // Width, Height, PixelFormat VideoParameters(int, int, string) (Parameters, error) // Return version information for the media manager as a set of // metadata Version() []Metadata // Log error messages with arguments Errorf(string, ...any) // Log warning messages with arguments Warningf(string, ...any) // Log info messages with arguments Infof(string, ...any) }
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
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, filtering by keys if any // are included. Use the "artwork" key to return only artwork. Metadata(...string) []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 CODEC // Codec // Set minimum and maximum values MIN = UNKNOWN MAX = CODEC // 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 { // Return the metadata key for the entry Key() string // Return the metadata value for the entry Value() any }
Metadata represents a metadata entry for a media stream.
type Opt ¶ added in v1.6.4
type Opt func(*opts) error
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 // Return number of planes for a specific PixelFormat // or SampleFormat and ChannelLayout combination NumPlanes() int }
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 }
Video parameters for encoding or decoding video data.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
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. |