device

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 5 Imported by: 0

README

Video For Linux Two

Build on Ubuntu

sudo apt install gcc-x86-64-linux-gnu
sudo apt install gcc-i686-linux-gnu
sudo apt install gcc-aarch64-linux-gnu binutils
sudo apt install gcc-arm-linux-gnueabihf
sudo apt install gcc-mipsel-linux-gnu

x86_64-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_x86_64
i686-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_i686
aarch64-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_aarch64
arm-linux-gnueabihf-gcc -w -static videodev2_arch.c -o videodev2_armhf
mipsel-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_mipsel -D_TIME_BITS=32

Documentation

Index

Constants

View Source
const (
	V4L2_PIX_FMT_YUYV  = 'Y' | 'U'<<8 | 'Y'<<16 | 'V'<<24
	V4L2_PIX_FMT_NV12  = 'N' | 'V'<<8 | '1'<<16 | '2'<<24
	V4L2_PIX_FMT_MJPEG = 'M' | 'J'<<8 | 'P'<<16 | 'G'<<24
	V4L2_PIX_FMT_H264  = 'H' | '2'<<8 | '6'<<16 | '4'<<24
	V4L2_PIX_FMT_HEVC  = 'H' | 'E'<<8 | 'V'<<16 | 'C'<<24
)
View Source
const (
	VIDIOC_QUERYCAP = 0x80685600
	VIDIOC_ENUM_FMT = 0xc0405602
	VIDIOC_G_FMT    = 0xc0d05604
	VIDIOC_S_FMT    = 0xc0d05605
	VIDIOC_REQBUFS  = 0xc0145608
	VIDIOC_QUERYBUF = 0xc0585609

	VIDIOC_QBUF      = 0xc058560f
	VIDIOC_DQBUF     = 0xc0585611
	VIDIOC_STREAMON  = 0x40045612
	VIDIOC_STREAMOFF = 0x40045613
	VIDIOC_G_PARM    = 0xc0cc5615
	VIDIOC_S_PARM    = 0xc0cc5616

	VIDIOC_ENUM_FRAMESIZES     = 0xc02c564a
	VIDIOC_ENUM_FRAMEINTERVALS = 0xc034564b
)
View Source
const (
	V4L2_BUF_TYPE_VIDEO_CAPTURE = 1
	V4L2_COLORSPACE_DEFAULT     = 0
	V4L2_FIELD_NONE             = 1
	V4L2_FRMIVAL_TYPE_DISCRETE  = 1
	V4L2_FRMSIZE_TYPE_DISCRETE  = 1
	V4L2_MEMORY_MMAP            = 1
)

Variables

View Source
var Formats = []Format{
	{V4L2_PIX_FMT_YUYV, "YUV 4:2:2", "yuyv422"},
	{V4L2_PIX_FMT_NV12, "Y/UV 4:2:0", "nv12"},
	{V4L2_PIX_FMT_MJPEG, "Motion-JPEG", "mjpeg"},
	{V4L2_PIX_FMT_H264, "H.264", "h264"},
	{V4L2_PIX_FMT_HEVC, "HEVC", "hevc"},
}

Functions

func NV12toYUV

func NV12toYUV(dst, src []byte)

func YUYVtoYUV

func YUYVtoYUV(dst, src []byte)

Types

type Capability

type Capability struct {
	Driver  string
	Card    string
	BusInfo string
	Version string
}

type Device

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

func Open

func Open(path string) (*Device, error)

func (*Device) Capability

func (d *Device) Capability() (*Capability, error)

func (*Device) Capture

func (d *Device) Capture() ([]byte, error)

func (*Device) Close

func (d *Device) Close() error

func (*Device) ListFormats

func (d *Device) ListFormats() ([]uint32, error)

func (*Device) ListFrameRates

func (d *Device) ListFrameRates(pixFmt, width, height uint32) ([]uint32, error)

func (*Device) ListSizes

func (d *Device) ListSizes(pixFmt uint32) ([][2]uint32, error)

func (*Device) SetFormat

func (d *Device) SetFormat(width, height, pixFmt uint32) error

func (*Device) SetParam

func (d *Device) SetParam(fps uint32) error

func (*Device) StreamOff

func (d *Device) StreamOff() (err error)

func (*Device) StreamOn

func (d *Device) StreamOn() (err error)

type Format

type Format struct {
	FourCC uint32
	Name   string
	FFmpeg string
}

Jump to

Keyboard shortcuts

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