 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Media services for golang, including bindings for ffmpeg, command line application
and backend REST API for extraction, multiplexing and transcoding.
Index ¶
- Constants
- type AudioChannel
- type AudioFormat
- type AudioFrame
- type ChannelLayout
- type Chromaprint
- type Codec
- type CommonParameters
- type Component
- type DecodeFn
- type DemuxFn
- type EncodingType
- type Frame
- type Manager
- type Map
- type Media
- type MediaFlag
- type MediaFormat
- type MediaKey
- type Metadata
- type Packet
- type PixelFormat
- type Port
- type PortCapabilityType
- type PortType
- type SWResample
- type SWResampleFn
- type SampleFormat
- type Stream
- type StreamType
- type VideoFrame
Constants ¶
const ( MMAL_COMPONENT_DEFAULT_VIDEO_DECODER = "vc.ril.video_decode" MMAL_COMPONENT_DEFAULT_VIDEO_ENCODER = "vc.ril.video_encode" MMAL_COMPONENT_DEFAULT_VIDEO_RENDERER = "vc.ril.video_render" MMAL_COMPONENT_DEFAULT_IMAGE_DECODER = "vc.ril.image_decode" MMAL_COMPONENT_DEFAULT_IMAGE_ENCODER = "vc.ril.image_encode" MMAL_COMPONENT_DEFAULT_CAMERA = "vc.ril.camera" MMAL_COMPONENT_DEFAULT_VIDEO_CONVERTER = "vc.video_convert" MMAL_COMPONENT_DEFAULT_SPLITTER = "vc.splitter" MMAL_COMPONENT_DEFAULT_SCHEDULER = "vc.scheduler" MMAL_COMPONENT_DEFAULT_VIDEO_INJECTER = "vc.video_inject" MMAL_COMPONENT_DEFAULT_VIDEO_SPLITTER = "vc.ril.video_splitter" MMAL_COMPONENT_DEFAULT_AUDIO_DECODER = "none" MMAL_COMPONENT_DEFAULT_AUDIO_RENDERER = "vc.ril.audio_render" MMAL_COMPONENT_DEFAULT_MIRACAST = "vc.miracast" MMAL_COMPONENT_DEFAULT_CLOCK = "vc.clock" MMAL_COMPONENT_DEFAULT_CAMERA_INFO = "vc.camera_info" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioChannel ¶ added in v1.6.1
type AudioChannel uint
AudioChannel specifies a single audio channel
const ( CHANNEL_NONE AudioChannel = iota CHANNEL_FRONT_LEFT CHANNEL_FRONT_RIGHT CHANNEL_FRONT_CENTER CHANNEL_LOW_FREQUENCY CHANNEL_BACK_LEFT CHANNEL_BACK_RIGHT CHANNEL_FRONT_LEFT_OF_CENTER CHANNEL_FRONT_RIGHT_OF_CENTER CHANNEL_BACK_CENTER CHANNEL_SIDE_LEFT CHANNEL_SIDE_RIGHT CHANNEL_TOP_CENTER CHANNEL_TOP_FRONT_LEFT CHANNEL_TOP_FRONT_CENTER CHANNEL_TOP_FRONT_RIGHT CHANNEL_TOP_BACK_LEFT CHANNEL_TOP_BACK_CENTER CHANNEL_TOP_BACK_RIGHT CHANNEL_STEREO_LEFT CHANNEL_STEREO_RIGHT CHANNEL_WIDE_LEFT CHANNEL_WIDE_RIGHT CHANNEL_SURROUND_DIRECT_LEFT CHANNEL_SURROUND_DIRECT_RIGHT CHANNEL_LOW_FREQUENCY_2 CHANNEL_TOP_SIDE_LEFT CHANNEL_TOP_SIDE_RIGHT CHANNEL_BOTTOM_FRONT_CENTER CHANNEL_BOTTOM_FRONT_LEFT CHANNEL_BOTTOM_FRONT_RIGHT CHANNEL_MAX = CHANNEL_BOTTOM_FRONT_RIGHT )
func (AudioChannel) String ¶ added in v1.6.1
func (v AudioChannel) String() string
type AudioFormat ¶ added in v1.5.1
type AudioFormat struct {
	// Sample rate in Hz
	Rate uint
	// Sample format
	Format SampleFormat
	// Channel layout
	Layout ChannelLayout
}
    AudioFormat specifies the interface for audio format
func (AudioFormat) String ¶ added in v1.5.1
func (v AudioFormat) String() string
type AudioFrame ¶ added in v1.6.1
type AudioFrame interface {
	// Returns the audio format, if MEDIA_FLAG_AUDIO is set
	AudioFormat() AudioFormat
	// Number of samples, if MEDIA_FLAG_AUDIO is set
	NumSamples() int
	// Audio channels, if MEDIA_FLAG_AUDIO is set
	Channels() []AudioChannel
	// Duration of the frame, if MEDIA_FLAG_AUDIO is set
	Duration() time.Duration
}
    type ChannelLayout ¶ added in v1.6.1
type ChannelLayout uint
ChannelLayout specifies the layout of channels
const ( CHANNEL_LAYOUT_NONE ChannelLayout = iota CHANNEL_LAYOUT_MONO CHANNEL_LAYOUT_STEREO CHANNEL_LAYOUT_2POINT1 CHANNEL_LAYOUT_2_1 CHANNEL_LAYOUT_SURROUND CHANNEL_LAYOUT_3POINT1 CHANNEL_LAYOUT_4POINT0 CHANNEL_LAYOUT_4POINT1 CHANNEL_LAYOUT_2_2 CHANNEL_LAYOUT_QUAD CHANNEL_LAYOUT_5POINT0 CHANNEL_LAYOUT_5POINT1 CHANNEL_LAYOUT_5POINT0_BACK CHANNEL_LAYOUT_5POINT1_BACK CHANNEL_LAYOUT_6POINT0 CHANNEL_LAYOUT_6POINT0_FRONT CHANNEL_LAYOUT_HEXAGONAL CHANNEL_LAYOUT_6POINT1 CHANNEL_LAYOUT_6POINT1_BACK CHANNEL_LAYOUT_6POINT1_FRONT CHANNEL_LAYOUT_7POINT0 CHANNEL_LAYOUT_7POINT0_FRONT CHANNEL_LAYOUT_7POINT1 CHANNEL_LAYOUT_7POINT1_WIDE CHANNEL_LAYOUT_7POINT1_WIDE_BACK CHANNEL_LAYOUT_OCTAGONAL CHANNEL_LAYOUT_HEXADECAGONAL CHANNEL_LAYOUT_STEREO_DOWNMIX CHANNEL_LAYOUT_22POINT2 CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER )
func (ChannelLayout) String ¶ added in v1.6.1
func (v ChannelLayout) String() string
type Chromaprint ¶ added in v1.6.1
type Chromaprint interface {
	io.Closer
	// Write sample data to the fingerprinter. Expects 16-bit signed integers
	// and returns number of samples written
	Write([]int16) (int64, error)
	// Finish the fingerprinting, and compute the fingerprint, return as a
	// string
	Finish() (string, error)
}
    Chromaprint is a wrapper around the chromaprint library. Create a new Chromaprint object by calling chromaprint.New(sample_rate, channels)
type Codec ¶ added in v1.6.1
type Codec interface {
	// Name returns the unique name for the codec
	Name() string
	// Description returns the long description for the codec
	Description() string
	// Flags for the codec (Audio, Video, Encoder, Decoder)
	Flags() MediaFlag
}
    Codec is an encoder or decoder for a specific media type
type CommonParameters ¶
type CommonParameters interface {
	// Get Parameters
	SupportedEncodings() ([]EncodingType, error)
	ZeroCopy() (bool, error)
	PowerMonEnable() (bool, error)
	NoImagePadding() (bool, error)
	LockstepEnable() (bool, error)
	// Set Parameters
	SetZeroCopy(bool) error
	SetPowerMonEnable(bool) error
	SetNoImagePadding(bool) error
	SetLockstepEnable(bool) error
}
    type DecodeFn ¶ added in v1.6.1
DecodeFn is a function which is called for each frame in the media, which is associated with a single stream. The function should return an error if the decode should be terminated.
type DemuxFn ¶ added in v1.6.1
Demux is a function which is called for each packet in the media, which is associated with a single stream. The function should return an error if the decode should be terminated.
type EncodingType ¶
type EncodingType uint32
func (EncodingType) String ¶
func (e EncodingType) String() string
type Frame ¶ added in v1.6.1
type Frame interface {
	AudioFrame
	VideoFrame
	// Returns MEDIA_FLAG_VIDEO, MEDIA_FLAG_AUDIO
	Flags() MediaFlag
}
    Frame is a decoded video or audio frame
type Manager ¶ added in v1.6.1
type Manager interface {
	io.Closer
	// Enumerate formats with MEDIA_FLAG_ENCODER, MEDIA_FLAG_DECODER,
	// MEDIA_FLAG_FILE and MEDIA_FLAG_DEVICE flags to filter.
	// Lookups can be further filtered by name, mimetype and extension
	MediaFormats(MediaFlag, ...string) []MediaFormat
	// Open media file for reading and return it. A format can be specified
	// to "force" a specific format
	OpenFile(string, MediaFormat) (Media, error)
	// Open media URL for reading and return it. A format can be specified
	// to "force" a specific format
	OpenURL(string, MediaFormat) (Media, error)
	// Open media device with a specific name for reading and return it.
	OpenDevice(string) (Media, error)
	// Create file for writing and return it
	CreateFile(string) (Media, error)
	// Create an output device with a specific name for writing and return it
	CreateDevice(string) (Media, error)
	// Create a map of input media. If MediaFlag is MEDIA_FLAG_NONE, then
	// all audio, video and subtitle streams are mapped, or else a
	// combination of MEDIA_FLAG_AUDIO,
	// MEDIA_FLAG_VIDEO, MEDIA_FLAG_SUBTITLE and MEDIA_FLAG_DATA
	// can be used to map specific types of streams.
	Map(Media, MediaFlag) (Map, error)
	// Demux a media file, passing packets to a callback function
	Demux(context.Context, Map, DemuxFn) error
	// Decode a packet into a series of frames, passing decoded frames to
	// a callback function
	Decode(context.Context, Map, Packet, DecodeFn) error
	// Log messages from ffmpeg
	SetDebug(bool)
}
    Manager is an interface to the ffmpeg media library for media manipulation
type Map ¶ added in v1.6.1
type Map interface {
	// Return input media
	Input() Media
	// Return a single stream which is mapped for decoding, filtering by
	// stream type. Returns nil if there is no selection of that type
	Streams(MediaFlag) []Stream
	// Print a summary of the mapping
	PrintMap(w io.Writer)
	// Resample an audio stream
	Resample(AudioFormat, Stream) error
}
    Map is a mapping of input media, potentially to output media
type Media ¶
type Media interface {
	io.Closer
	// URL for the media
	URL() string
	// Return enumeration of streams
	Streams() []Stream
	// Return media flags for the media
	Flags() MediaFlag
	// Return the format of the media
	Format() MediaFormat
	// Return metadata for the media
	Metadata() Metadata
	// Set metadata value by key, or remove it if the value is nil
	Set(MediaKey, any) error
}
    Media is a source or destination of media
type MediaFlag ¶ added in v1.5.1
type MediaFlag uint
MediaFlag is a bitfield of flags for media, including type of media
const ( MEDIA_FLAG_ALBUM MediaFlag = (1 << iota) // Is part of an album MEDIA_FLAG_ALBUM_TRACK // Is an album track MEDIA_FLAG_ALBUM_COMPILATION // Album is a compilation MEDIA_FLAG_TVSHOW // Is part of a TV Show MEDIA_FLAG_TVSHOW_EPISODE // Is a TV Show episode MEDIA_FLAG_FILE // Is a file MEDIA_FLAG_DEVICE // Is a device MEDIA_FLAG_VIDEO // Contains video MEDIA_FLAG_AUDIO // Contains audio MEDIA_FLAG_SUBTITLE // Contains subtitles MEDIA_FLAG_DATA // Contains data stream MEDIA_FLAG_ATTACHMENT // Contains attachment MEDIA_FLAG_ARTWORK // Contains artwork MEDIA_FLAG_CAPTIONS // Contains captions MEDIA_FLAG_ENCODER // Is an encoder MEDIA_FLAG_DECODER // Is an decoder MEDIA_FLAG_NONE MediaFlag = 0 MEDIA_FLAG_MAX = MEDIA_FLAG_DECODER )
func (MediaFlag) FlagString ¶ added in v1.5.1
type MediaFormat ¶ added in v1.6.1
type MediaFormat interface {
	// Return the names of the media format
	Name() []string
	// Return a longer description of the media format
	Description() string
	// Return MEDIA_FLAG_ENCODER, MEDIA_FLAG_DECODER, MEDIA_FLAG_FILE
	// and MEDIA_FLAG_DEVICE flags
	Flags() MediaFlag
	// Return mimetypes handled
	MimeType() []string
	// Return file extensions handled
	Ext() []string
	// Return the default audio codec for the format
	DefaultAudioCodec() Codec
	// Return the default video codec for the format
	DefaultVideoCodec() Codec
	// Return the default subtitle codec for the format
	DefaultSubtitleCodec() Codec
}
    MediaFormat is an input or output format for media items
type MediaKey ¶ added in v1.5.1
type MediaKey string
MediaKey is a string which is used for media metadata
const ( MEDIA_KEY_BRAND_MAJOR MediaKey = "major_brand" // string MEDIA_KEY_BRAND_COMPATIBLE MediaKey = "compatible_brands" // string MEDIA_KEY_CREATED MediaKey = "creation_time" // time.Time MEDIA_KEY_ENCODER MediaKey = "encoder" // string MEDIA_KEY_ALBUM MediaKey = "album" // string MEDIA_KEY_ALBUM_ARTIST MediaKey = "artist" // string MEDIA_KEY_COMMENT MediaKey = "comment" // string MEDIA_KEY_COMPOSER MediaKey = "composer" // string MEDIA_KEY_COPYRIGHT MediaKey = "copyright" // string MEDIA_KEY_YEAR MediaKey = "date" // uint MEDIA_KEY_DISC MediaKey = "disc" // uint xx or xx/yy MEDIA_KEY_ENCODED_BY MediaKey = "encoded_by" // string MEDIA_KEY_FILENAME MediaKey = "filename" // string MEDIA_KEY_GENRE MediaKey = "genre" // string MEDIA_KEY_LANGUAGE MediaKey = "language" // string MEDIA_KEY_PERFORMER MediaKey = "performer" // string MEDIA_KEY_PUBLISHER MediaKey = "publisher" // string MEDIA_KEY_SERVICE_NAME MediaKey = "service_name" // string MEDIA_KEY_SERVICE_PROVIDER MediaKey = "service_provider" // string MEDIA_KEY_TITLE MediaKey = "title" // string MEDIA_KEY_TRACK MediaKey = "track" // uint xx or xx/yy MEDIA_KEY_VERSION_MAJOR MediaKey = "major_version" // string MEDIA_KEY_VERSION_MINOR MediaKey = "minor_version" // string MEDIA_KEY_SHOW MediaKey = "show" // string MEDIA_KEY_SEASON MediaKey = "season_number" // uint MEDIA_KEY_EPISODE_SORT MediaKey = "episode_sort" // string MEDIA_KEY_EPISODE_ID MediaKey = "episode_id" // uint MEDIA_KEY_COMPILATION MediaKey = "compilation" // bool MEDIA_KEY_GAPLESS_PLAYBACK MediaKey = "gapless_playback" // bool MEDIA_KEY_ACCOUNT_ID MediaKey = "account_id" // string MEDIA_KEY_DESCRIPTION MediaKey = "description" // string MEDIA_KEY_MEDIA_TYPE MediaKey = "media_type" // string MEDIA_KEY_PURCHASED MediaKey = "purchase_date" // time.Time MEDIA_KEY_ALBUM_SORT MediaKey = "sort_album" // string MEDIA_KEY_ARTIST_SORT MediaKey = "sort_artist" // string MEDIA_KEY_TITLE_SORT MediaKey = "sort_name" // string MEDIA_KEY_SYNOPSIS MediaKey = "synopsis" // string MEDIA_KEY_GROUPING MediaKey = "grouping" // string )
type Metadata ¶ added in v1.6.1
type Metadata interface {
	// Return enumeration of keys
	Keys() []MediaKey
	// Return value for key
	Value(MediaKey) any
}
    Metadata embedded in the media
type Packet ¶ added in v1.6.1
type Packet interface {
	// Flags returns the flags for the packet from the stream
	Flags() MediaFlag
	// Stream returns the stream which the packet belongs to
	Stream() Stream
	// IsKeyFrame returns true if the packet contains a key frame
	IsKeyFrame() bool
	// Pos returns the byte position of the packet in the media
	Pos() int64
	// Duration returns the duration of the packet
	Duration() time.Duration
	// Size of the packet in bytes
	Size() int
	// Bytes returns the raw bytes of the packet
	Bytes() []byte
}
    Packet is a single unit of data in the media
type PixelFormat ¶ added in v1.6.1
type PixelFormat int
PixelFormat specifies the encoding of pixel within a frame
const ( PIXEL_FORMAT_YUV420P PixelFormat = iota PIXEL_FORMAT_NONE PixelFormat = -1 )
func (PixelFormat) String ¶ added in v1.6.1
func (f PixelFormat) String() string
type Port ¶
type Port interface {
	// Return port information
	Name() string
	Type() PortType
	Index() uint
	Capabilities() PortCapabilityType
	// Enable & Disable port
	Enabled() bool
	SetEnabled(bool) error
	// Connect and disconnect this port to another
	Connect(Port) error
	Disconnect() error
	// Flush port, commit format changes
	Flush() error
	Commit() error
	// Implements common parameters
	CommonParameters
}
    type PortCapabilityType ¶
type PortCapabilityType uint32
const ( MMAL_PORT_CAPABILITY_NONE PortCapabilityType = 0x00 MMAL_PORT_CAPABILITY_PASSTHROUGH PortCapabilityType = 0x01 MMAL_PORT_CAPABILITY_ALLOCATION PortCapabilityType = 0x02 MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE PortCapabilityType = 0x04 MMAL_PORT_CAPABILITY_MIN PortCapabilityType = MMAL_PORT_CAPABILITY_PASSTHROUGH MMAL_PORT_CAPABILITY_MAX PortCapabilityType = MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE )
func (PortCapabilityType) String ¶
func (t PortCapabilityType) String() string
type SWResample ¶ added in v1.6.1
type SWResample interface {
	io.Closer
	// Create a new empty context object for conversion, with an input frame which
	// will be used to store the data and the target output format.
	Convert(AudioFrame, AudioFormat, SWResampleFn) error
}
    SWResample is an interface to the ffmpeg swresample library which resamples audio.
type SWResampleFn ¶ added in v1.6.1
type SWResampleFn func(AudioFrame) error
SWResampleFn is a function that accepts an "output" audio frame, which can be nil if the conversion has not started yet, and should fill the audio frame provided to the Convert function. Should return io.EOF on end of conversion, or any other error to stop the conversion.
type SampleFormat ¶ added in v1.6.1
type SampleFormat uint
SampleFormat specifies the type of a single sample
const ( SAMPLE_FORMAT_NONE SampleFormat = iota SAMPLE_FORMAT_U8 // Byte SAMPLE_FORMAT_S16 // Signed 16-bit SAMPLE_FORMAT_S32 // Signed 32-bit SAMPLE_FORMAT_S64 // Signed 64-bit SAMPLE_FORMAT_FLT // Float 32-bit SAMPLE_FORMAT_DBL // Float 64-bit SAMPLE_FORMAT_U8P // Planar byte SAMPLE_FORMAT_S16P // Planar signed 16-bit SAMPLE_FORMAT_S32P // Planar signed 32-bit SAMPLE_FORMAT_S64P // Planar signed 64-bit SAMPLE_FORMAT_FLTP // Planar float 32-bit SAMPLE_FORMAT_DBLP // Planar float 64-bit SAMPLE_FORMAT_MAX = SAMPLE_FORMAT_DBLP )
func (SampleFormat) String ¶ added in v1.6.1
func (v SampleFormat) String() string
type Stream ¶ added in v1.6.1
type Stream interface {
	// Return index of stream in the media
	Index() int
	// Return media flags for the stream
	Flags() MediaFlag
	// Return artwork for the stream - if MEDIA_FLAG_ARTWORK is set
	Artwork() []byte
}
    Stream of data multiplexed in the media
type StreamType ¶
type StreamType uint32
const ( MMAL_ES_TYPE_NONE StreamType = 0x0000 MMAL_ES_TYPE_CONTROL StreamType = 0x0001 MMAL_ES_TYPE_AUDIO StreamType = 0x0002 MMAL_ES_TYPE_VIDEO StreamType = 0x0003 MMAL_ES_TYPE_SUBPICTURE StreamType = 0x0004 )
func (StreamType) String ¶
func (s StreamType) String() string
type VideoFrame ¶ added in v1.6.1
type VideoFrame interface {
	// Returns the audio format, if MEDIA_FLAG_VIDEO is set
	PixelFormat() PixelFormat
	// Return frame width and height, if MEDIA_FLAG_VIDEO is set
	Size() (int, int)
}
    
       Directories
      ¶
      Directories
      ¶
    
    | Path | Synopsis | 
|---|---|
| cmd
       | |
| 
          
            _mediatool
            
            command
          
          
         | |
| 
          
            _photosync
            
            command
          
          
         | |
| An example of extracting artwork from media files. | An example of extracting artwork from media files. | 
| 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. | 
| hw
       | |
| 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. | 
| plugin
       | |
| 
          
            _media
            
            command
          
          
         | |
| sys
       | |
| 
          
            _ffmpeg
            
            
          
           Package ffmpeg provides low-level ffmpeg for go | Package ffmpeg provides low-level ffmpeg for go | 
| An example of extracting frames from a video. | An example of extracting frames from a video. |