Documentation
¶
Index ¶
- Constants
- func NewPacketDecoder(codec *ff.AVCodecContext, stream int) (*decoder, error)
- func NewResampler(format ff.AVSampleFormat, opt ...Opt) (*resampler, error)
- func NewRescaler(format ff.AVPixelFormat, opt ...Opt) (*rescaler, error)
- type DecodeFn
- type Encoder
- type EncoderFrameFn
- type EncoderPacketFn
- type Frame
- func (frame *Frame) AVFrame() *ff.AVFrame
- func (frame *Frame) Bytes(plane int) []byte
- func (frame *Frame) ChannelLayout() string
- func (frame *Frame) Height() int
- func (frame *Frame) Id() int
- func (frame *Frame) Image() (image.Image, error)
- func (frame *Frame) Int16(plane int) []int16
- func (frame *Frame) MarshalJSON() ([]byte, error)
- func (frame *Frame) NumPlanes() int
- func (frame *Frame) NumSamples() int
- func (frame *Frame) PixelFormat() string
- func (frame *Frame) SampleFormat() string
- func (frame *Frame) Samplerate() int
- func (frame *Frame) Stride(plane int) int
- func (frame *Frame) String() string
- func (frame *Frame) Time() time.Duration
- func (frame *Frame) Type() media.MediaType
- func (frame *Frame) Width() int
- type Metadata
- type Opt
- func OptChannelLayout(layout string) Opt
- func OptChannels(num int) Opt
- func OptForce() Opt
- func OptFrameSize(size string) Opt
- func OptMetadata(entry ...*Metadata) Opt
- func OptOutputFormat(name string) Opt
- func OptPixFormat(format string) Opt
- func OptSampleFormat(format string) Opt
- func OptSampleRate(rate int) Opt
- func OptStream(stream int, par *Par) Opt
- func OptWidthHeight(w, h int) Opt
- type Par
- func AudioPar(samplefmt string, channellayout string, samplerate int) *Par
- func NewAudioPar(samplefmt string, channellayout string, samplerate int) (*Par, error)
- func NewVideoPar(pixfmt string, size string, framerate float64) (*Par, error)
- func VideoPar(pixfmt string, size string, framerate float64) *Par
- type Writer
Constants ¶
const (
MetaArtwork = "artwork" // Metadata key for artwork, set the value as []byte
)
Variables ¶
This section is empty.
Functions ¶
func NewPacketDecoder ¶
func NewPacketDecoder(codec *ff.AVCodecContext, stream int) (*decoder, error)
func NewResampler ¶
func NewResampler(format ff.AVSampleFormat, opt ...Opt) (*resampler, error)
Create a new audio resampler which will resample the input frame to the specified channel layout, sample rate and sample format.
func NewRescaler ¶
func NewRescaler(format ff.AVPixelFormat, opt ...Opt) (*rescaler, error)
Create a new rescaler which will rescale the input frame to the specified format, width and height.
Types ¶
type DecodeFn ¶
DecodeFn is a function which is called for each frame decoded with the stream id of the packet. It should return nil to continue decoding or io.EOF to stop decoding.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
Create an encoder with the given parameters
func (*Encoder) Encode ¶
func (e *Encoder) Encode(frame *ff.AVFrame, fn EncoderPacketFn) error
Encode a frame and pass packets to the EncoderPacketFn. If the frame is nil, then the encoder will flush any remaining packets. If io.EOF is returned then it indicates that the encoder has ended prematurely.
func (*Encoder) MarshalJSON ¶
type EncoderFrameFn ¶
EncoderFrameFn is a function which is called to receive a frame to encode. It should return nil to continue encoding or io.EOF to stop encoding.
type EncoderPacketFn ¶
type EncoderPacketFn func(*ff.AVPacket, *ff.AVRational) error
EncoderPacketFn is a function which is called for each packet encoded, with the stream timebase.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
func (*Frame) MarshalJSON ¶
func (*Frame) NumPlanes ¶
Return the number of planes for a specific PixelFormat or SampleFormat and ChannelLayout combination
type Metadata ¶
type Metadata struct { Key string `json:"key" writer:",width:30"` Value any `json:"value,omitempty" writer:",wrap,width:50"` }
func NewMetadata ¶
type Opt ¶
type Opt func(*opts) error
func OptForce ¶
func OptForce() Opt
Force resampling and resizing on decode, even if the input and output parameters are the same
func OptMetadata ¶
Append metadata to the output file, including artwork
type Par ¶
type Par struct {
ff.AVCodecParameters
}
func NewAudioPar ¶
func (*Par) CopyToCodec ¶
func (ctx *Par) CopyToCodec(codec *ff.AVCodecContext) error
func (*Par) MarshalJSON ¶
func (*Par) ValidateFromCodec ¶
func (ctx *Par) ValidateFromCodec(codec *ff.AVCodecContext) error
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Create media from io.Writer
func (*Writer) Encode ¶
func (w *Writer) Encode(in EncoderFrameFn, out EncoderPacketFn) error
Encode frames from all encoders, calling the callback function to encode the frame. If the callback function returns io.EOF then the encoding for that encoder is stopped after flushing. If the second callback is nil, then packets are written to the output.