ffmpeg

package
v0.0.0-...-f3a3104 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dummy

func Dummy(format string, acodec string, vcodec string) (io.Reader, error)

Dummy create a reader that is a dummy media file with requested format and codecs

func DurationToPosition

func DurationToPosition(d time.Duration) string

DurationToPosition time.Duration to ffmpeg position format

Types

type AudioCodec

type AudioCodec string

type Codec

type Codec interface {
	// contains filtered or unexported methods
}

type FFmpeg

type FFmpeg struct {
	Streams  []Stream
	Stderr   io.Writer
	DebugLog Printer
	// contains filtered or unexported fields
}

FFmpeg instance

func (*FFmpeg) Start

func (f *FFmpeg) Start(ctx context.Context) error

func (*FFmpeg) Wait

func (f *FFmpeg) Wait() error

Wait for ffmpeg to finish

type Format

type Format struct {
	Name  string
	Flags []string
}

Format output format

type Input

type Input interface {
	// contains filtered or unexported methods
}

type Map

type Map struct {
	Input      Input  // many streams can use same the input
	Specifier  string // 0, a:0, v:0, etc
	Codec      Codec
	CodecFlags []string
}

Map input stream to output stream

type Metadata

type Metadata struct {
	Album string `json:"album"` // name of the set this work belongs to
	// main creator of the set/album, if different from artist.
	// e.g. "Various Artists" for compilation albums.
	AlbumArtist  string `json:"album_artist"`
	Artist       string `json:"artist"`        // main creator of the work
	Comment      string `json:"comment"`       // any additional description of the file.
	Composer     string `json:"composer"`      // who composed the work, if different from artist.
	Copyright    string `json:"copyright"`     // name of copyright holder.
	CreationTime string `json:"creation_time"` // date when the file was created, preferably in ISO 8601.
	Date         string `json:"date"`          // date when the work was created, preferably in ISO 8601.
	Disc         string `json:"disc"`          // number of a subset, e.g. disc in a multi-disc collection.
	Encoder      string `json:"encoder"`       // name/settings of the software/hardware that produced the file.
	EncodedBy    string `json:"encoded_by"`    // person/group who created the file.
	Filename     string `json:"filename"`      // original name of the file.
	Genre        string `json:"genre"`         // <self-evident>.
	// main language in which the work is performed, preferably
	// in ISO 639-2 format. Multiple languages can be specified by
	// separating them with commas.
	Language string `json:"language"`
	// artist who performed the work, if different from artist.
	// E.g for "Also sprach Zarathustra", artist would be "Richard
	// Strauss" and performer "London Philharmonic Orchestra".
	Performer       string `json:"performer"`
	Publisher       string `json:"publisher"`        // name of the label/publisher.
	ServiceName     string `json:"service_name"`     // name of the service in broadcasting (channel name).
	ServiceProvider string `json:"service_provider"` // name of the service provider in broadcasting.
	Title           string `json:"title"`            // name of the work.
	Track           string `json:"track"`            // number of this work in the set, can be in form current/total.
	VariantBitrate  string `json:"variant_bitrate"`  // the total bitrate of the bitrate variant that the current stream is part of
}

from libavformat/avformat.h json tag is used for metadata key name also

func (Metadata) Map

func (m Metadata) Map() map[string]string

func (Metadata) Merge

func (a Metadata) Merge(b Metadata) Metadata

type Output

type Output interface {
	// contains filtered or unexported methods
}

type Printer

type Printer interface {
	Printf(format string, v ...interface{})
}

type ProbeFormat

type ProbeFormat struct {
	Filename       string   `json:"filename"`
	FormatName     string   `json:"format_name"`
	FormatLongName string   `json:"format_long_name"`
	StartTime      string   `json:"start_time"`
	Duration       string   `json:"duration"`
	Size           string   `json:"size"`
	BitRate        string   `json:"bit_rate"`
	ProbeScore     uint     `json:"probe_score"`
	Tags           Metadata `json:"tags"`
}

type ProbeInfo

type ProbeInfo struct {
	Format  ProbeFormat            `json:"format"`
	Streams []ProbeStream          `json:"streams"`
	Raw     map[string]interface{} `json:"-"`
}

ProbeInfo ffprobe result

func Probe

func Probe(ctx context.Context, i Input, debugLog Printer, stderr io.Writer) (pi ProbeInfo, err error)

Probe run ffprobe with context

func (ProbeInfo) AudioCodec

func (pi ProbeInfo) AudioCodec() string

AudioCodec probed audio codec

func (ProbeInfo) Duration

func (pi ProbeInfo) Duration() time.Duration

Duration probed duration

func (ProbeInfo) FindStreamType

func (pi ProbeInfo) FindStreamType(codecType string) (ProbeStream, bool)

func (ProbeInfo) FormatName

func (pi ProbeInfo) FormatName() string

FormatName probed format

func (ProbeInfo) String

func (pi ProbeInfo) String() string

func (ProbeInfo) SubtitleCodec

func (pi ProbeInfo) SubtitleCodec() string

SubtitleCodec probed audio codec

func (*ProbeInfo) UnmarshalJSON

func (pi *ProbeInfo) UnmarshalJSON(text []byte) error

func (ProbeInfo) VideoCodec

func (pi ProbeInfo) VideoCodec() string

VideoCodec probed video codec

type ProbeStream

type ProbeStream struct {
	Index          uint   `json:"index"`
	CodecName      string `json:"codec_name"`
	CodecLongName  string `json:"codec_long_name"`
	CodecType      string `json:"codec_type"`
	CodecTimeBase  string `json:"codec_time_base"`
	CodecTagString string `json:"codec_tag_string"`
	CodecTag       string `json:"codec_tag"`
	SampleFmt      string `json:"sample_fmt"`
	SampleRate     string `json:"sample_rate"`
	Channels       uint   `json:"channels"`
	ChannelLayout  string `json:"channel_layout"`
	BitsPerSample  uint   `json:"bits_per_sample"`
	RFrameRate     string `json:"r_frame_rate"`
	AvgFrameRate   string `json:"avg_frame_rate"`
	TimeBase       string `json:"time_base"`
	StartPts       int64  `json:"start_pts"`
	StartTime      string `json:"start_time"`
	DurationTs     uint64 `json:"duration_ts"`
	Duration       string `json:"duration"`
	BitRate        string `json:"bit_rate"`
}

type Reader

type Reader struct {
	Reader io.Reader
}

Reader read from a io.Reader is a struct as a interface can't be a receiver

type Stream

type Stream struct {
	InputFlags  []string
	OutputFlags []string
	Maps        []Map
	Format      Format
	Metadata    Metadata
	Output      Output
}

type SubtitleCodec

type SubtitleCodec string

type URL

type URL string

URL read or write to URL (local file path, pipe:, https:// etc)

type VideoCodec

type VideoCodec string

type Writer

type Writer struct {
	Writer io.WriteCloser
}

Writer write to a io.WriteCloser

Jump to

Keyboard shortcuts

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