media

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: Apache-2.0 Imports: 3 Imported by: 6

README

go-media

This module provides an interface for media services, including:

  • Bindings in golang for ffmpeg;
  • Opening media files for reading and writing;
  • Retrieving metadata and artwork from audio and video media;
  • Re-multiplexing media files from one format to another;
  • Serve a backend API for access to media services.

Presently the module is in development and the API is subject to change.

If you want to... Folder Documentation
Use the lower-level ffmpeg bindings similar to the C API sys/ffmpeg README.md
Use the high-level media manager package for reading, writing, multiplexing and transcoding pkg/media README.md
Implement or use a REST API for media files plugin/media README.md
See example command-line tools cmd README.md

Requirements

  • Library and header files for ffmpeg;
  • Library and header files for chromaprint;
  • go1.17 or later;
  • Tested on Debian Linux (32- and 64- bit) on ARM and macOS on x64 architectures.

Building

This module does not include a full copy of ffmpeg as part of the build process, but expects pkgconfig files libavcodec.pc, libavdevice.pc, libavfilter.pc, libavformat.pc, libavresample.pc and libavutil.pc to be present (and an existing set of header files and libraries to be available to link against, of course).

You may need two environment variables set in order to locate the correct installation of ffmpeg:

  • PKG_CONFIG_PATH is used for locating the pkgconfig files;
  • DYLD_LIBRARY_PATH is used for locating a dynamic library when testing and/or running if linked dynamically.

On Macintosh with homebrew, for example:

[bash] brew install ffmpeg chromaprint
[bash] git clone git@github.com:djthorpe/go-media.git
[bash] cd go-media
[bash] PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" make

On Debian Linux you shouldn't need to locate the correct path to the sqlite3 library, since only one copy is installed:

[bash] sudo apt install libavcodec-dev libavdevice-dev libavfilter-dev \
       libavformat-dev libavresample-dev libavutil-dev libchromaprint-dev
[bash] git clone git@github.com:djthorpe/go-media.git
[bash] cd go-media
[bash] 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 server plugins will install the backend server and required plugins in the build folder;
  • make clean will remove all build artifacts.

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, David Thorpe, All rights reserved.

Documentation

Overview

Media services for golang, including bindings for ffmpeg, command line application

and backend REST API for extraction, multiplexing and transcoding.

Index

Constants

This section is empty.

Variables

View Source
var (
	AudioLayoutMono   = AudioChannelLayout{1}
	AudioLayoutStereo = AudioChannelLayout{2}
)

Functions

This section is empty.

Types

type AudioChannelLayout

type AudioChannelLayout struct {
	Channels uint
}

AudioChannelLayout represents number of channels and layout of those channels

type AudioFormat

type AudioFormat int

AudioFormat represents how the samples are stored

const (
	AUDIO_FMT_NONE AudioFormat = iota
	AUDIO_FMT_U8               // unsigned 8 bits
	AUDIO_FMT_U8P              // unsigned 8 bits, planar
	AUDIO_FMT_S16              // signed 16 bits
	AUDIO_FMT_S16P             // signed 16 bits, planar
	AUDIO_FMT_S32              // signed 32 bits
	AUDIO_FMT_S32P             // signed 32 bits, planar
	AUDIO_FMT_F32              // float32
	AUDIO_FMT_F32P             // float32, planar
	AUDIO_FMT_F64              // float64
	AUDIO_FMT_F64P             // float64, planar
	AUDIO_FMT_S64              // signed 64 bits
	AUDIO_FMT_S64P             // signed 64 bits, planar
)

func (AudioFormat) String

func (f AudioFormat) String() string

type DecodeIteratorFunc

type DecodeIteratorFunc func(context.Context, MediaPacket) error

type Media

type Media interface {
	URL() *url.URL    // Return URL for the media location
	Flags() MediaFlag // Return flags
}

Media represents either input or output media

type MediaCodec

type MediaCodec 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
}

MediaCodec is the codec and parameters

type MediaFlag

type MediaFlag uint64
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 compliation
	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_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_MIN                         = MEDIA_FLAG_ALBUM
	MEDIA_FLAG_MAX                         = MEDIA_FLAG_DECODER
)

func (MediaFlag) FlagString

func (f MediaFlag) FlagString() string

func (MediaFlag) Is

func (f MediaFlag) Is(v MediaFlag) bool

func (MediaFlag) String

func (f MediaFlag) String() string

type MediaKey

type MediaKey string
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
	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
	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 MediaPacket

type MediaPacket interface {
	Size() int
	Bytes() []byte
	Stream() int
}

MediaPacket is a packet of data from a stream

Directories

Path Synopsis
cmd
mediatool command
pkg
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
_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
ffmpeg
Package ffmpeg provides low-level ffmpeg for go
Package ffmpeg provides low-level ffmpeg for go

Jump to

Keyboard shortcuts

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