ffmpeg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ffmpeg binds the parts of FFmpeg's C API the pipeline uses, through purego, and refuses library versions it does not name.

Index

Constants

View Source
const (
	SeekBackward = 1
	SeekAny      = 4

	DiscardDefault = 0
	DiscardAll     = 48

	ColorSpaceBT709     = 1
	ColorSpaceBT2020NCL = 9
	ColorSpaceBT2020CL  = 10

	PictTypeNone int32 = 0
	PictTypeI    int32 = 1

	ColorPrimariesBT709       = 1
	ColorPrimariesUnspecified = 2
	ColorPrimariesBT2020      = 9

	ColorTrcBT709       = 1
	ColorTrcUnspecified = 2
	ColorTrcSMPTE2084   = 16 // PQ (HDR10)
	ColorTrcARIBSTDB67  = 18 // HLG
)
View Source
const NoPTS int64 = math.MinInt64

NoPTS is AV_NOPTS_VALUE, a timestamp that is not known.

View Source
const TimeBase = 1000000

TimeBase is AV_TIME_BASE, the microseconds a format's duration counts.

Variables

View Source
var (
	// ErrEOF is AVERROR_EOF: the input or a decoder has nothing more.
	ErrEOF = tag('E', 'O', 'F', ' ')
	// ErrExit is AVERROR_EXIT: an interrupt callback stopped a call.
	ErrExit = tag('E', 'X', 'I', 'T')
	// ErrAgain is AVERROR(EAGAIN): a decoder needs input or output first.
	ErrAgain = Error(-eagain())
	// ErrInvalidData is AVERROR_INVALIDDATA.
	ErrInvalidData = tag('I', 'N', 'D', 'A')
)
View Source
var Majors = map[string]int{
	"avutil":     61,
	"swresample": 7,
	"swscale":    10,
	"avcodec":    63,
	"avformat":   63,
	"avfilter":   12,
}

Majors are the library major versions the binding's struct layouts are generated for (FFmpeg 9). Fields only move between majors, so any minor release of these loads.

Functions

func Alloc

func Alloc(n int) unsafe.Pointer

Alloc allocates n bytes FFmpeg may write, aligned for its SIMD code.

func DecoderSupportsHW

func DecoderSupportsHW(decoderName, hwDevice string) bool

DecoderSupportsHW reports whether decoderName supports hwDevice and that hardware device can be opened on this machine.

func Dir

func Dir() string

Dir is the directory the libraries were loaded from, empty for the system's search, once Load succeeded.

func Free

func Free(p unsafe.Pointer)

Free frees memory from Alloc.

func HasDecoder

func HasDecoder(name string) bool

HasDecoder reports whether FFmpeg has a decoder with name compiled in.

func HasDemuxer

func HasDemuxer(name string) bool

HasDemuxer reports the loaded FFmpeg having the demuxer name, such as "dash", which libraries built without libxml2 lack.

func HasEncoder

func HasEncoder(name string) bool

HasEncoder reports whether FFmpeg has an encoder with name compiled in.

func HasMuxer

func HasMuxer(name string) bool

HasMuxer reports the loaded FFmpeg having the muxer name, such as "spdif".

func IsAgain

func IsAgain(err error) bool

IsAgain reports err being ErrAgain.

func IsEOF

func IsEOF(err error) bool

IsEOF reports err being ErrEOF.

func Load

func Load() error

Load loads FFmpeg's libraries once, from the first directory of library.Dirs that holds them all at the majors the binding names, and binds their functions. Later calls return the first call's result.

func PixelFormat

func PixelFormat(name string) int32

PixelFormat is the number of a pixel format FFmpeg names, -1 if none.

func PixelFormatName

func PixelFormatName(f int32) string

PixelFormatName is a pixel format's name.

func SampleFormat

func SampleFormat(name string) int32

SampleFormat is the number of a sample format FFmpeg names, -1 if none.

func Version

func Version() string

Version is the loaded FFmpeg's version string, such as "9.0.2".

Types

type Chapter

type Chapter struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func (*Chapter) End

func (c *Chapter) End() int64

func (*Chapter) ID

func (c *Chapter) ID() int64

func (*Chapter) Metadata

func (c *Chapter) Metadata() map[string]string

func (*Chapter) Start

func (c *Chapter) Start() int64

func (*Chapter) TimeBase

func (c *Chapter) TimeBase() Rational

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

type CodecContext

type CodecContext struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

type CodecParameters

type CodecParameters struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func (*CodecParameters) BitRate

func (c *CodecParameters) BitRate() int64

func (*CodecParameters) Channels

func (c *CodecParameters) Channels() int

func (*CodecParameters) CodecID

func (c *CodecParameters) CodecID() int32

func (*CodecParameters) CodecName

func (c *CodecParameters) CodecName() string

CodecName is the codec's short name, such as "h264".

func (*CodecParameters) Format

func (c *CodecParameters) Format() int32

func (*CodecParameters) Height

func (c *CodecParameters) Height() int

func (*CodecParameters) Profile

func (c *CodecParameters) Profile() int32

func (*CodecParameters) Rotation

func (c *CodecParameters) Rotation() int

Rotation is the clockwise rotation in degrees, a multiple of 90, the stream's display matrix asks the picture to be shown at.

func (*CodecParameters) SampleAspectRatio

func (c *CodecParameters) SampleAspectRatio() Rational

func (*CodecParameters) SampleRate

func (c *CodecParameters) SampleRate() int

func (*CodecParameters) Type

func (c *CodecParameters) Type() MediaType

func (*CodecParameters) Width

func (c *CodecParameters) Width() int

type D3D11Surface

type D3D11Surface struct {
	Texture unsafe.Pointer // ID3D11Texture2D
	Index   int            // the array slice
	Device  unsafe.Pointer // ID3D11Device
	Context unsafe.Pointer // ID3D11DeviceContext, used under Lock
	// contains filtered or unexported fields
}

D3D11Surface is where a D3D11VA frame decoded: a slice of a texture array on the decoder's device.

func (D3D11Surface) Lock

func (s D3D11Surface) Lock()

Lock takes the lock FFmpeg holds while it uses the device's context.

func (D3D11Surface) Unlock

func (s D3D11Surface) Unlock()

Unlock releases what Lock took.

type Decoder

type Decoder struct {

	// HWDevice is the device type it decodes on, empty for software.
	HWDevice string
	// contains filtered or unexported fields
}

Decoder is an opened decoder for one stream.

func NewDecoder

func NewDecoder(par *CodecParameters, tb Rational, threads int, hwDevice string, extraHW int) (*Decoder, error)

NewDecoder opens a decoder for par's codec, with threads threads (0 for FFmpeg's choice) and, when hwDevice names one, on that hardware device type ("videotoolbox", "d3d11va", "vaapi"), whose pool keeps extraHW surfaces beyond what decoding needs for frames the caller holds. It fails when the codec has no decoder or the device cannot be made for it.

func NewRawDecoder

func NewRawDecoder(codecName string, threads int, hwDevice string) (*Decoder, error)

NewRawDecoder opens a low-latency decoder by codec name (such as "h264") without container parameters, for raw access-unit streams. When hwDevice names a hardware device type ("videotoolbox", "d3d11va", "vaapi"), it opens on that device.

func (*Decoder) Close

func (d *Decoder) Close()

Close frees the decoder and its device.

func (*Decoder) DecodeSubtitle

func (d *Decoder) DecodeSubtitle(p *Packet) (*Subtitle, error)

DecodeSubtitle decodes a subtitle packet, returning nil for a packet that completes none.

func (*Decoder) Flush

func (d *Decoder) Flush()

Flush drops the decoder's buffered packets and frames, as after a seek.

func (*Decoder) Receive

func (d *Decoder) Receive(f *Frame) error

Receive takes the next decoded frame into f. ErrAgain means it needs more packets; ErrEOF that it is drained.

func (*Decoder) Send

func (d *Decoder) Send(p *Packet) error

Send gives the decoder a packet; nil drains it. ErrAgain means frames must be received first.

func (*Decoder) Size

func (d *Decoder) Size() (w, h int)

Size is the decoder's picture size, which a subtitle decoder sets to its canvas once a packet tells it; 0 until then.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder is an opened FFmpeg video encoder.

func NewEncoder

func NewEncoder(cfg EncoderConfig) (*Encoder, error)

NewEncoder opens a video encoder with no B-frames for low-latency encoding.

func (*Encoder) Close

func (e *Encoder) Close()

Close frees the encoder and any hardware contexts it owns.

func (*Encoder) Name

func (e *Encoder) Name() string

Name is the FFmpeg encoder name.

func (*Encoder) Receive

func (e *Encoder) Receive(p *Packet) error

Receive reads the next encoded packet into p. ErrAgain means more frames are needed; ErrEOF that the encoder is drained.

func (*Encoder) Send

func (e *Encoder) Send(f *Frame) error

Send submits a software frame (or nil to flush). When the encoder uses a hardware frame pool (such as VAAPI), Send uploads f to a hardware surface.

func (*Encoder) SetBitRate

func (e *Encoder) SetBitRate(bps int64)

SetBitRate updates the encoder context's target bit rate in bits per second.

type EncoderConfig

type EncoderConfig struct {
	Name       string // FFmpeg encoder name, e.g. "h264_videotoolbox"
	HWDevice   string // optional hardware device for frame upload, e.g. "vaapi"
	HWFormat   string // hardware pixel format when HWDevice is set, e.g. "vaapi"
	PixFmt     string // software pixel format fed in, e.g. "nv12" or "yuv420p"
	Width      int
	Height     int
	FPS        int
	BitRate    int64
	GOPSize    int
	ColorSpace int32
	FullRange  bool
	Options    map[string]string
}

EncoderConfig configures a low-latency video encoder.

type Error

type Error int32

Error is a negative error code an FFmpeg function returned.

func (Error) Error

func (e Error) Error() string

type FormatContext

type FormatContext struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func (*FormatContext) BitRate

func (c *FormatContext) BitRate() int64

BitRate is the input's total bit rate, 0 when unknown.

func (*FormatContext) Chapters

func (c *FormatContext) Chapters() []*Chapter

Chapters are the input's chapters.

func (*FormatContext) Duration

func (c *FormatContext) Duration() time.Duration

Duration is the input's duration, 0 when unknown.

func (*FormatContext) FormatName

func (c *FormatContext) FormatName() string

FormatName is the demuxer's short name, such as "matroska,webm".

func (*FormatContext) Metadata

func (c *FormatContext) Metadata() map[string]string

Metadata is the container's metadata.

func (*FormatContext) ReadPacket

func (c *FormatContext) ReadPacket(p *Packet) error

ReadPacket reads the next packet into p.

func (*FormatContext) Seek

func (c *FormatContext) Seek(stream int, minTS, ts, maxTS int64, flags int) error

Seek seeks to ts in stream's time base, or microseconds for stream -1, within [minTS, maxTS].

func (*FormatContext) Seekable

func (c *FormatContext) Seekable() bool

Seekable reports the demuxer able to seek, which a live stream's is not.

func (*FormatContext) StartTime

func (c *FormatContext) StartTime() time.Duration

StartTime is the first timestamp's time, 0 when unknown.

func (*FormatContext) Streams

func (c *FormatContext) Streams() []*Stream

Streams are the input's streams.

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func NewFrame

func NewFrame() *Frame

NewFrame allocates an empty frame.

func (*Frame) AllocBuffer

func (f *Frame) AllocBuffer(w, h int, pixFmt int32) error

AllocBuffer allocates buffers for a software video frame of w×h pixels in pixFmt.

func (*Frame) BestEffortTimestamp

func (f *Frame) BestEffortTimestamp() int64

func (*Frame) Channels

func (f *Frame) Channels() int

func (*Frame) Clone

func (f *Frame) Clone() *Frame

Clone is a new frame referencing f's buffers, nil when out of memory.

func (*Frame) ColorPrimaries

func (f *Frame) ColorPrimaries() int32

func (*Frame) ColorSpace

func (f *Frame) ColorSpace() int32

func (*Frame) ColorTrc

func (f *Frame) ColorTrc() int32

func (*Frame) CopyColor

func (f *Frame) CopyColor(src *Frame)

CopyColor gives f src's color space, range, transfer characteristic and primaries.

func (*Frame) D3D11

func (f *Frame) D3D11() (s D3D11Surface, ok bool)

D3D11 is a D3D11VA frame's surface; ok is false for other frames.

func (*Frame) DurationTS

func (f *Frame) DurationTS() int64

func (*Frame) Format

func (f *Frame) Format() int32

func (*Frame) Free

func (f *Frame) Free()

Free frees the frame and its buffers.

func (*Frame) FullRange

func (f *Frame) FullRange() bool

func (*Frame) HDR

func (f *Frame) HDR() bool

HDR reports a picture with a high dynamic range transfer characteristic (PQ / HDR10 or HLG).

func (*Frame) Hardware

func (f *Frame) Hardware() bool

Hardware reports a frame in a hardware surface, which Transfer copies into memory.

func (*Frame) Height

func (f *Frame) Height() int

func (*Frame) Key

func (f *Frame) Key() bool

func (*Frame) MakeWritable

func (f *Frame) MakeWritable() error

MakeWritable ensures the frame's buffers can be written in place.

func (*Frame) MoveTo

func (f *Frame) MoveTo(dst *Frame)

MoveTo moves the frame's buffers into dst, leaving f empty.

func (*Frame) NbSamples

func (f *Frame) NbSamples() int

func (*Frame) PTS

func (f *Frame) PTS() int64

func (*Frame) Plane

func (f *Frame) Plane(i int) (unsafe.Pointer, int)

Plane is the frame's i-th data pointer and its line size.

func (*Frame) SampleRate

func (f *Frame) SampleRate() int

func (*Frame) SetColor

func (f *Frame) SetColor(colorspace int32, fullRange bool)

SetColor sets the frame's color space and range.

func (*Frame) SetGeometry

func (f *Frame) SetGeometry(w, h int, pixFmt int32)

SetGeometry sets a wrapper frame's width, height and pixel format.

func (*Frame) SetPTS

func (f *Frame) SetPTS(ts int64)

SetPTS sets the frame's timestamp.

func (*Frame) SetPictType

func (f *Frame) SetPictType(t int32)

SetPictType sets the frame's picture type (PictTypeNone or PictTypeI).

func (*Frame) SetPlane

func (f *Frame) SetPlane(i int, data unsafe.Pointer, stride int)

SetPlane sets the i-th plane pointer and line size directly, for wrapping caller-owned buffers without copying. Clear it before freeing.

func (*Frame) SoftwareFormat

func (f *Frame) SoftwareFormat() int32

SoftwareFormat is the pixel format a hardware frame's surface holds, such as nv12 or p010le, -1 for a frame in memory.

func (*Frame) TransferTo

func (f *Frame) TransferTo(dst *Frame) error

TransferTo copies a hardware frame's picture into dst, in memory.

func (*Frame) Unref

func (f *Frame) Unref()

Unref drops the frame's buffers, keeping it for reuse.

func (*Frame) VAAPI

func (f *Frame) VAAPI() (display unsafe.Pointer, surface uint32, ok bool)

VAAPI is a VAAPI frame's display and surface; ok is false for other frames.

func (*Frame) Width

func (f *Frame) Width() int

type Input

type Input struct {
	Format *FormatContext
	// contains filtered or unexported fields
}

Input is an opened media source: its demuxer, and the Go reader and interrupt behind it.

func Open

func Open(url string, src Source, interrupt *atomic.Bool) (*Input, error)

Open opens url, or src when it is not nil (url then only names it), and reads its streams' information. Setting interrupt makes any blocking call on the input return ErrExit.

func OpenInput

func OpenInput(url string, src Source, interrupt *atomic.Bool, o InputOptions) (*Input, error)

OpenInput is Open with the demuxer, its options and an Opener for the resources it opens itself.

func (*Input) Close

func (in *Input) Close()

Close closes the demuxer and the custom I/O.

func (*Input) ReadErr

func (in *Input) ReadErr() error

ReadErr is the last error the Go source returned, if any.

type InputOptions

type InputOptions struct {
	// Format names the demuxer, such as "hls", instead of probing.
	Format string
	// Options are the demuxer's options, such as hls' "allowed_extensions".
	Options map[string]string
	// Open, when not nil, opens every resource the demuxer opens itself.
	Open Opener
}

InputOptions are how OpenInput opens its input.

type MediaType

type MediaType int32

MediaType is AVMediaType.

const (
	MediaVideo      MediaType = 0
	MediaAudio      MediaType = 1
	MediaData       MediaType = 2
	MediaSubtitle   MediaType = 3
	MediaAttachment MediaType = 4
)

type Opener

type Opener func(url string, options map[string]string) (Source, error)

Opener opens a resource a demuxer asks for by URL, such as an HLS playlist's segments or keys, as a Source read through Go. Options are what the demuxer passes with the request, such as "offset" and "end_offset" for a byte range. A Source that is an io.Closer is closed when the demuxer closes it.

type Packer

type Packer struct {
	// contains filtered or unexported fields
}

Packer wraps a stream's encoded audio packets in IEC 61937 bursts, as S/PDIF and HDMI carry AC-3, E-AC-3, DTS, DTS-HD and TrueHD to a receiver that decodes them, through FFmpeg's spdif muxer. The bursts are 16-bit little-endian words, which a carrier plays as PCM frames: 2 channels, or 8 for HDMI's high bit rate.

func NewPacker

func NewPacker(par *CodecParameters, dtsHDRate int) (*Packer, error)

NewPacker makes a packer for the stream whose parameters are par: AC-3, E-AC-3, DTS or TrueHD, whose access units it gathers into MAT frames. A DTS stream passes its core alone unless dtsHDRate is set: then whole frames, DTS-HD's extension substream with the core, pass as DTS type IV bursts at that IEC 61937 rate, 768000 for HDMI's high bit rate.

func (*Packer) Close

func (k *Packer) Close()

Close frees the packer.

func (*Packer) Pack

func (k *Packer) Pack(p *Packet) ([]byte, error)

Pack wraps p, which becomes the packer's to change, and returns the bursts it completed, valid until the next call: none while E-AC-3 gathers the frames of one burst, or TrueHD the 24 access units of a MAT frame. The packet's stream index and timestamps are changed for the muxer.

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func NewPacket

func NewPacket() *Packet

NewPacket allocates an empty packet.

func (*Packet) DTS

func (p *Packet) DTS() int64

func (*Packet) Data

func (p *Packet) Data() []byte

Data is the packet's bytes, valid until it is unreferenced.

func (*Packet) DurationTS

func (p *Packet) DurationTS() int64

func (*Packet) Free

func (p *Packet) Free()

Free frees the packet and its data.

func (*Packet) Key

func (p *Packet) Key() bool

func (*Packet) PTS

func (p *Packet) PTS() int64

func (*Packet) Pos

func (p *Packet) Pos() int64

func (*Packet) SetData

func (p *Packet) SetData(b []byte) error

SetData replaces the packet's payload with a copy of b.

func (*Packet) Size

func (p *Packet) Size() int

func (*Packet) StreamIndex

func (p *Packet) StreamIndex() int

func (*Packet) Unref

func (p *Packet) Unref()

Unref drops the packet's data, keeping it for reuse.

type Rational

type Rational struct{ Num, Den int32 }

Rational is AVRational.

func (Rational) Duration

func (r Rational) Duration(ts int64) time.Duration

Duration is ts in r's units.

func (Rational) Float

func (r Rational) Float() float64

Float is r as a number, 0 for a zero denominator.

func (Rational) Units

func (r Rational) Units(d time.Duration) int64

Units is d in r's units, rounded down.

type Resampler

type Resampler struct {
	// contains filtered or unexported fields
}

Resampler converts decoded audio to interleaved float32 at a rate and channel count, rebuilding its context when the source's format changes.

func NewResampler

func NewResampler(rate, channels int) *Resampler

NewResampler converts to rate and channels.

func (*Resampler) Close

func (r *Resampler) Close()

Close frees the resampler.

func (*Resampler) Convert

func (r *Resampler) Convert(f *Frame) ([]float32, error)

Convert converts f and returns the samples, interleaved, valid until the next call.

func (*Resampler) Reset

func (r *Resampler) Reset()

Reset drops what the resampler holds, as after a seek.

type Scaler

type Scaler struct {
	// contains filtered or unexported fields
}

Scaler converts video frames to RGBA at a size through swscale's frame API, which follows each frame's color space and range and splits the work over the CPU's cores.

func (*Scaler) Close

func (s *Scaler) Close()

Close frees the context.

func (*Scaler) Convert

func (s *Scaler) Convert(dst, src *Frame) error

Convert scales and converts src into dst, both already configured with their geometry, pixel format and plane buffers.

func (*Scaler) Scale

func (s *Scaler) Scale(f *Frame, dst unsafe.Pointer, stride, w, h int) error

Scale converts f into dst, w×h pixels with rows of stride bytes of RGBA, in memory from Alloc. HDR frames (PQ and HLG) are tone-mapped to sRGB.

type Source

type Source interface {
	io.ReadSeeker
	Size() int64
}

Source is what Open reads through Go instead of a URL FFmpeg opens: an HTTP body, or any other seekable stream. Size, when it returns a positive length, lets FFmpeg seek from the end.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

The pointer types below stand for FFmpeg's structs; their memory is FFmpeg's, and their methods read and write fields at the offsets layout.go generated.

func (*Stream) AttachedPicture

func (s *Stream) AttachedPicture() bool

AttachedPicture reports a video stream that is only cover art.

func (*Stream) AvgFrameRate

func (s *Stream) AvgFrameRate() Rational

func (*Stream) Default

func (s *Stream) Default() bool

Default reports the container marking the stream as its default.

func (*Stream) Duration

func (s *Stream) Duration() time.Duration

Duration is the stream's duration, 0 when unknown.

func (*Stream) DurationTS

func (s *Stream) DurationTS() int64

func (*Stream) Forced

func (s *Stream) Forced() bool

Forced reports a subtitle stream marked forced.

func (*Stream) FrameCount

func (s *Stream) FrameCount() int64

func (*Stream) ID

func (s *Stream) ID() int

func (*Stream) Index

func (s *Stream) Index() int

func (*Stream) Metadata

func (s *Stream) Metadata() map[string]string

func (*Stream) Params

func (s *Stream) Params() *CodecParameters

func (*Stream) RealFrameRate

func (s *Stream) RealFrameRate() Rational

func (*Stream) SampleAspectRatio

func (s *Stream) SampleAspectRatio() Rational

func (*Stream) SetDiscard

func (s *Stream) SetDiscard(d int32)

SetDiscard sets which of the stream's packets the demuxer drops.

func (*Stream) StartTime

func (s *Stream) StartTime() int64

func (*Stream) TimeBase

func (s *Stream) TimeBase() Rational

type Subtitle

type Subtitle struct {
	// PTS is in microseconds, NoPTS when unknown.
	PTS        int64
	Start, End uint32 // End is math.MaxUint32 when unknown
	Rects      []SubtitleRect
}

Subtitle is a decoded subtitle: what shows from Start to End milliseconds after PTS, replacing what its stream showed before. No rects clear the screen, as PGS and DVB end a subtitle.

type SubtitleRect

type SubtitleRect struct {
	Text string
	ASS  string
	X, Y int
	// Image is a bitmap's pixels, premultiplied as image.RGBA is; nil
	// for text.
	Image *image.RGBA
}

SubtitleRect is one part of a decoded subtitle: plain text, an ASS event line, or a bitmap at X, Y on the stream's canvas.

type Tempo

type Tempo struct {
	// contains filtered or unexported fields
}

Tempo changes interleaved float32 audio's speed while keeping its pitch, through FFmpeg's atempo filter.

func NewTempo

func NewTempo(rate, channels int, factor float64) (*Tempo, error)

NewTempo makes a filter speeding audio of rate and channels up by factor, from 0.25 to 4.

func (*Tempo) Close

func (t *Tempo) Close()

Close frees the filter.

func (*Tempo) Process

func (t *Tempo) Process(samples []float32, dst []float32) ([]float32, error)

Process feeds samples in and appends what the filter gives out to dst.

Directories

Path Synopsis
Package library finds FFmpeg's shared libraries: the directory the NSGO_MEDIA_FFMPEG environment variable names, the app's package, beside the executable, then the system's.
Package library finds FFmpeg's shared libraries: the directory the NSGO_MEDIA_FFMPEG environment variable names, the app's package, beside the executable, then the system's.

Jump to

Keyboard shortcuts

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