Documentation
¶
Index ¶
- func Read(filename string, buffer ...[]byte) (int, int, []byte, error)
- func Write(filename string, width, height int, buffer []byte) error
- type Camera
- func (camera *Camera) Close()
- func (camera *Camera) Codec() string
- func (camera *Camera) Depth() int
- func (camera *Camera) FPS() float64
- func (camera *Camera) FrameBuffer() []byte
- func (camera *Camera) Height() int
- func (camera *Camera) Name() string
- func (camera *Camera) Read() bool
- func (camera *Camera) SetFrameBuffer(buffer []byte) error
- func (camera *Camera) Width() int
- type Options
- type Video
- func (video *Video) Bitrate() int
- func (video *Video) Close()
- func (video *Video) Codec() string
- func (video *Video) Depth() int
- func (video *Video) Duration() float64
- func (video *Video) FPS() float64
- func (video *Video) FileName() string
- func (video *Video) FrameBuffer() []byte
- func (video *Video) Frames() int
- func (video *Video) HasStreams() bool
- func (video *Video) Height() int
- func (video *Video) MetaData() map[string]string
- func (video *Video) Read() bool
- func (video *Video) ReadFrame(n int) error
- func (video *Video) ReadFrames(n ...int) ([]*image.RGBA, error)
- func (video *Video) SetFrameBuffer(buffer []byte) error
- func (video *Video) Stream() int
- func (video *Video) Width() int
- type VideoWriter
- func (writer *VideoWriter) Bitrate() int
- func (writer *VideoWriter) Close()
- func (writer *VideoWriter) Codec() string
- func (writer *VideoWriter) Delay() int
- func (writer *VideoWriter) FPS() float64
- func (writer *VideoWriter) FileName() string
- func (writer *VideoWriter) Height() int
- func (writer *VideoWriter) Loop() int
- func (writer *VideoWriter) Macro() int
- func (writer *VideoWriter) Quality() float64
- func (writer *VideoWriter) StreamFile() string
- func (writer *VideoWriter) Width() int
- func (writer *VideoWriter) Write(frame []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Camera ¶
type Camera struct {
// contains filtered or unexported fields
}
func NewCamera ¶
Creates a new camera struct that can read from the device with the given stream index.
func (*Camera) FrameBuffer ¶
func (*Camera) SetFrameBuffer ¶
type Options ¶
type Options struct { Bitrate int // Bitrate. Loop int // For GIFs only. -1=no loop, 0=infinite loop, >0=number of loops. Delay int // Delay for final frame of GIFs in centiseconds. Macro int // Macroblock size for determining how to resize frames for codecs. FPS float64 // Frames per second for output video. Quality float64 // If bitrate not given, use quality instead. Must be between 0 and 1. 0:best, 1:worst. Codec string // Codec for video. StreamFile string // File path for extra stream data. }
Optional parameters for VideoWriter.
type Video ¶
type Video struct {
// contains filtered or unexported fields
}
func NewVideoStreams ¶
Read all video streams from the given file.
func (*Video) FrameBuffer ¶
func (*Video) HasStreams ¶
Returns true if file has any audio, subtitle, data or attachment streams.
func (*Video) Read ¶
Reads the next frame from the video and stores in the framebuffer. If the last frame has been read, returns false, otherwise true.
func (*Video) ReadFrame ¶
Reads the N-th frame from the video and stores it in the framebuffer. If the index is out of range or the operation failes, the function will return an error. The frames are indexed from 0.
func (*Video) ReadFrames ¶
Read the N-amount of frames with the given indexes and return them as a slice of RGBA image pointers. If one of the indexes is out of range, the function will return an error. The frames are indexes from 0.
func (*Video) SetFrameBuffer ¶
type VideoWriter ¶
type VideoWriter struct {
// contains filtered or unexported fields
}
func NewVideoWriter ¶
func NewVideoWriter(filename string, width, height int, options *Options) (*VideoWriter, error)
Creates a new VideoWriter struct with default values from the Options struct.
func (*VideoWriter) Close ¶
func (writer *VideoWriter) Close()
Closes the pipe and stops the ffmpeg process.
func (*VideoWriter) Codec ¶
func (writer *VideoWriter) Codec() string
func (*VideoWriter) Delay ¶
func (writer *VideoWriter) Delay() int
Delay for final frame of GIFs in centiseconds.
func (*VideoWriter) FileName ¶
func (writer *VideoWriter) FileName() string
func (*VideoWriter) Height ¶
func (writer *VideoWriter) Height() int
func (*VideoWriter) Loop ¶
func (writer *VideoWriter) Loop() int
For GIFs only, defines looping behavior. -1=no loop, 0=infinite loop, >0=number of loops.
func (*VideoWriter) Macro ¶
func (writer *VideoWriter) Macro() int
Macroblock size for determining how to resize frames for codecs.
func (*VideoWriter) Quality ¶
func (writer *VideoWriter) Quality() float64
Video Codec Quality parameter. Must be between 0 and 1. 0:best, 1:worst.
func (*VideoWriter) StreamFile ¶
func (writer *VideoWriter) StreamFile() string
File used to fill in extra stream data.
func (*VideoWriter) Width ¶
func (writer *VideoWriter) Width() int
func (*VideoWriter) Write ¶
func (writer *VideoWriter) Write(frame []byte) error
Writes the given frame to the video file.