media

package module
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 7

README

go-media

This module provides an interface for media services, including:

  • Bindings in golang for ffmpeg 6;
  • Opening media files, devices and network sockets for reading and writing;
  • Retrieving metadata and artwork from audio and video media;
  • Re-multiplexing media files from one format to another;
  • Fingerprinting audio files to identify music.

Current Status

This module is currently in development and subject to change. If there are any specific features you are interested in, please see below "Contributing & Distribution" below.

Requirements

In order to build the examples, you'll need the library and header files for ffmpeg 6 installed. The chromaprint library is also required for fingerprinting audio files. On Macintosh with homebrew, for example:

brew install ffmpeg@6 chromaprint make

There are some examples in the cmd folder of the main repository on how to use the package. The various make targets are:

  • make all will perform tests, build all examples and the backend API;
  • make test will perform tests;
  • make cmd will build example command-line tools into the build folder;
  • make clean will remove all build artifacts.

There are also some targets to build a docker image:

  • DOCKER_REGISTRY=docker.io/user make docker will build a docker image;
  • DOCKER_REGISTRY=docker.io/user make docker-push will push the docker image to the registry.

For example,

git clone git@github.com:djthorpe/go-media.git
cd go-media
DOCKER_REGISTRY=ghcr.io/mutablelogic make docker

Examples

Media Transcoding

Audio Fingerprinting

You can programmatically fingerprint audio files, compare fingerprints and identify music using the following packages:

  • sys/chromaprint provides the implementation of the lower-level function calls to chromaprint. The documentation is here
  • pkg/chromaprint provides the higher-level API for fingerprinting and identifying music. The documentation is here.

You'll need an API key in order to use the AcoustID service. You can get a key here.

Contributing & Distribution

This module is currently in development and subject to change.

Please do file feature requests and bugs here. The license is Apache 2 so feel free to redistribute. Redistributions in either source code or binary form must reproduce the copyright notice, and please link back to this repository for more information:

Copyright (c) 2021-2024 David Thorpe, All rights reserved.

References

Documentation

Overview

media is a package for reading and writing media files.

Index

Constants

This section is empty.

Variables

View Source
var NativeEndian binary.ByteOrder

NativeEndian is the ByteOrder of the current system.

Functions

func NewManager added in v1.6.2

func NewManager() *manager

func NewReader added in v1.6.1

func NewReader(r io.Reader, mimetype string) (*reader, error)

Create a new reader from an io.Reader

func Open added in v1.6.1

func Open(url string, mimetype string) (*reader, error)

Open a reader from a url or file path, and either use the mimetype or guess the format otherwise. Returns a media object.

Types

type Decoder added in v1.6.1

type Decoder interface{}

Decoder represents a decoder for a media stream.

type DecoderFunc added in v1.6.1

type DecoderFunc func(Decoder, Packet) error

DecoderFunc is a function that decodes a packet

type Frame added in v1.5.1

type Frame interface{}

Frame represents a frame of audio or video data.

type FrameFunc added in v1.6.1

type FrameFunc func(Frame) error

FrameFunc is a function that processes a frame of audio or video data.

type InputFormat added in v1.6.2

type InputFormat interface{}

InputFormat represents a container format for input of media streams.

type Media

type Media interface {
	io.Closer

	// Return the metadata for the media stream.
	Metadata() []Metadata

	// Demultiplex media (when NewReader or Open has
	// been used). Pass a packet to a decoder function.
	Demux(DecoderFunc) error

	// Return a decode function, which can rescale or
	// resample a frame and then call a frame processing
	// function for encoding and multiplexing.
	Decode(FrameFunc) DecoderFunc
}

Media represents a media stream, which can be input or output. A new media object is created using NewReader, Open, NewWriter or Create.

type MediaType added in v1.6.1

type MediaType uint32

Media type flags

const (
	UNKNOWN  MediaType = (1 << iota) // Usually treated as DATA
	VIDEO                            // Video stream
	AUDIO                            // Audio stream
	DATA                             // Opaque data information usually continuous
	SUBTITLE                         // Subtitle stream
	ATTACHMENT
)

type Metadata added in v1.5.1

type Metadata interface{}

Metadata represents a metadata entry for a media stream.

type OutputFormat added in v1.6.2

type OutputFormat interface{}

OuputFormat represents a container format for output of media streams.

type Packet added in v1.5.1

type Packet interface{}

Packet represents a packet of demultiplexed data.

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
cli
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL