Documentation ¶
Index ¶
- func InitLocalCamera(camera *Camera) error
- 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)
- func (camera *Camera) SetFramerate(framerate string)
- func (camera *Camera) Width() int
- type Options
- type RTSPCamera
- type Video
- func (video *Video) AudioCodec() string
- 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) Height() int
- func (video *Video) PixFmt() string
- func (video *Video) Read() bool
- func (video *Video) SetFrameBuffer(buffer []byte)
- func (video *Video) Width() int
- type VideoWriter
- func (writer *VideoWriter) AudioCodec() string
- 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) Width() int
- func (writer *VideoWriter) Write(frame []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLocalCamera ¶
Once the user calls Read() for the first time on a Camera struct, the ffmpeg command which is used to read the camera device is started.
Types ¶
type Camera ¶
type Camera struct {
// contains filtered or unexported fields
}
func NewLocalCamera ¶
Creates a new camera struct that can read from the device with the given stream index.
func (*Camera) FrameBuffer ¶
func (*Camera) SetFrameBuffer ¶
Sets the framebuffer to the given byte array. Note that "buffer" must be large enough to store one frame of video data which is width*height*3.
func (*Camera) SetFramerate ¶
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. 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. Audio string // File path for audio. If no audio, audio="". AudioCodec string // Codec for audio. }
Optional parameters for VideoWriter.
type RTSPCamera ¶
type RTSPCamera struct {
// contains filtered or unexported fields
}
func NewRtspCamera ¶
func NewRtspCamera(id, username, password, streamUri string) (*RTSPCamera, error)
Creates a new camera struct that can read from the device with the given stream index.
func (*RTSPCamera) Camera ¶
func (cam *RTSPCamera) Camera() *Camera
func (*RTSPCamera) GetCameraData ¶
func (cam *RTSPCamera) GetCameraData() error
Get camera meta data such as width, height, fps and codec.
func (*RTSPCamera) InitCamera ¶
func (cam *RTSPCamera) InitCamera() error
Once the user calls Read() for the first time on a Camera struct, the ffmpeg command which is used to read the camera device is started.
type Video ¶
type Video struct {
// contains filtered or unexported fields
}
func NewVideo ¶
Creates a new Video struct. Uses ffprobe to get video information and fills in the Video struct with this data.
func (*Video) AudioCodec ¶
func (*Video) FrameBuffer ¶
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) SetFrameBuffer ¶
Sets the framebuffer to the given byte array. Note that "buffer" must be large enough to store one frame of video data which is width*height*3.
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) AudioCodec ¶
func (writer *VideoWriter) AudioCodec() string
func (*VideoWriter) Bitrate ¶
func (writer *VideoWriter) Bitrate() int
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
func (*VideoWriter) FPS ¶
func (writer *VideoWriter) FPS() float64
func (*VideoWriter) FileName ¶
func (writer *VideoWriter) FileName() string
func (*VideoWriter) Height ¶
func (writer *VideoWriter) Height() int
func (*VideoWriter) Loop ¶
func (writer *VideoWriter) Loop() int
func (*VideoWriter) Macro ¶
func (writer *VideoWriter) Macro() int
func (*VideoWriter) Quality ¶
func (writer *VideoWriter) Quality() float64
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.