media

package
v0.0.0-...-0805d90 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FormatMP4 is the MP4 container format (.mp4, video/mp4).
	FormatMP4 = &Format{
		Name:      "MP4",
		MIME:      "video/mp4",
		Extension: "mp4",
	}
	// FormatMKV is the Matroska container format (.mkv, video/x-matroska).
	FormatMKV = &Format{
		Name:      "MKV",
		MIME:      "video/x-matroska",
		Extension: "mkv",
	}
)

Functions

func SanitizeID

func SanitizeID(s string) string

SanitizeID sanitizes a string to be usable as a media ID. Example: "Test.mkv" -> "test-mkv"

func ValidID

func ValidID(s string) bool

ValidID checks whether the supplied string is a valid media ID.

Types

type BasicMedia

type BasicMedia struct {
	ID_     string
	Path_   string
	Meta_   meta.Metadata
	Format_ *Format
}

BasicMedia is a JSON-serializable generic Media.

func NewBasicMedia

func NewBasicMedia(m Media) *BasicMedia

NewBasicMedia wraps Media into BasicMedia.

func (*BasicMedia) Format

func (bm *BasicMedia) Format() *Format

func (*BasicMedia) ID

func (bm *BasicMedia) ID() string

func (*BasicMedia) MarshalJSON

func (bm *BasicMedia) MarshalJSON() ([]byte, error)

MarshalJSON marshals JSON data from this struct.

func (*BasicMedia) Meta

func (bm *BasicMedia) Meta() meta.Metadata

func (*BasicMedia) Path

func (bm *BasicMedia) Path() string

func (*BasicMedia) UnmarshalJSON

func (bm *BasicMedia) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshalls JSON data into this struct.

type Format

type Format struct {
	// Name is the container format name.
	Name string `json:"name"`
	// MIME is the format MIME type.
	MIME string `json:"mime"`
	// Extension is the format's preferred file extension, **without leading dots**.
	Extension string `json:"extension"`
}

Format is a media file container format.

func FindFormat

func FindFormat(name string) *Format

FindFormat tries to find a format by its name, returns nil if not found.

func FindFormatMIME

func FindFormatMIME(mime string) *Format

FindFormatMIME tries to find a format by its MIME type, returns nil if not found.

func FindUnsupportedFormat

func FindUnsupportedFormat(mime, ext string) *Format

FindUnsupportedFormat tries to find a format by its MIME type, creating an unsupported Format if not found.

func Formats

func Formats() []*Format

Formats returns all default formats.

func (*Format) Supported

func (f *Format) Supported() bool

Supported returns whether the format is known to available de/muxers.

type Media

type Media interface {
	// ID returns the media ID, alphanumeric, lowercase, non-blank ([a-z0-9-_]).
	ID() string
	// Path is the path of this media file, absolute.
	Path() string
	// Meta is the metadata object, may be nil.
	Meta() meta.Metadata
	// Format is the media format.
	Format() *Format
}

Media is a media file.

func NewMedia

func NewMedia(id, path string, meta0 meta.Metadata, format *Format) Media

NewMedia creates a Media with set values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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