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.
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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Err ¶ added in v1.7.2
type Err uint
const ( ErrBadParameter Err = http.StatusBadRequest ErrInternalError Err = http.StatusInternalServerError ErrNotImplemented Err = http.StatusNotImplemented )
type Format ¶ added in v1.6.3
type Format interface { // The type of the format, which can be combinations of // INPUT, OUTPUT, DEVICE, AUDIO, VIDEO and SUBTITLE Type() Type // The unique name that the format can be referenced as Name() string // Description of the format Description() string }
A container format for a media file
type FrameFunc ¶ added in v1.6.1
FrameFunc is a function which is called to send a frame after decoding. It should return nil to continue decoding or io.EOF to stop.
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, ...Par) (Media, error) // Return supported input and output container formats which match any filter, // which can be a name, extension (with preceeding period) or mimetype. The Type // can be a combination of DEVICE, INPUT, OUTPUT or ANY to select the right kind of // format Formats(Type, ...string) []Format // Return all supported sample formats SampleFormats() []Metadata // Return all supported pixel formats PixelFormats() []Metadata // Return standard channel layouts which can be used for audio, // with the number of channels provided. If no channels are provided, // then all standard channel layouts are returned. ChannelLayouts() []Metadata // Return all supported codecs, of a specific type or all // if ANY is used. If any names is provided, then only the codecs // with those names are returned. Codecs(Type, ...string) []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) // Decode an input stream, determining the streams to be decoded // and the function to accept the decoded frames. If MapFunc is nil, // all streams are passed through (demultiplexing). Decode(context.Context, Media, MapFunc, FrameFunc) error }
Manager represents a manager for media formats and devices. Create a new manager object using the NewManager function.
import "github.com/mutablelogic/go-media/pkg/ffmpeg" manager, err := ffmpeg.NewManager() if err != nil { ... }
Various options are available to control the manager, for logging and affecting decoding, that can be applied when creating the manager by passing them as arguments.
Only one manager can be created. If NewManager is called a second time, the previously created manager is returned, but any new options are applied.
type MapFunc ¶ added in v1.7.3
MapFunc return parameters if a stream should be decoded, resampled (for audio streams) or resized (for video streams). Return nil if you want to ignore the stream, or pass back the stream parameters if you want to copy the stream without any changes.
type Media ¶
type Media interface { io.Closer // The type of the format, which can be combinations of // INPUT or OUTPUT Type() Type }
A container format for a media file, reader, device or network stream
type Metadata ¶ added in v1.5.1
type Metadata interface { // Return the metadata key Key() string // Return the value as a string. Returns the mimetype // if the value is a byte slice, and the mimetype can be // detected. Value() string // Returns the value as a byte slice Bytes() []byte // Returns the value as an image Image() image.Image // Returns the value as an interface Any() any }
Metadata is a key/value pair which can be used to describe a media object or other metadata. The value can be retrieved as a string value, data, or other type. If the value is a byte slice, then it can also be retrieved as an image (for artwork)
type Type ¶ added in v1.6.7
type Type int
Type of codec, device, format or stream
const ( NONE Type = 0 // Type is not defined VIDEO Type = (1 << iota) // Type is video AUDIO // Type is audio SUBTITLE // Type is subtitle DATA // Type is data UNKNOWN // Type is unknown INPUT // Type is input format OUTPUT // Type is output format DEVICE // Type is input or output device ANY = NONE // Type is any (used for filtering) )
func (Type) FlagString ¶ added in v1.6.7
Return a flag as a string
func (Type) MarshalJSON ¶ added in v1.6.7
Return the type as a string
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
examples/sdlplayer
This example demonstrates how to play audio and video files using SDL2.
|
This example demonstrates how to play audio and video files using SDL2. |
etc
|
|
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 |
ffmpeg61
The low-level ffmpeg bindings for ffmpeg version 6.1.
|
The low-level ffmpeg bindings for ffmpeg version 6.1. |
ffmpeg71
The low-level ffmpeg bindings for ffmpeg version 6.1.
|
The low-level ffmpeg bindings for ffmpeg version 6.1. |