Error
device.GetPixFormat()
always fails with error device: pix format failed: unsupported error
if we do a system call trace i get following
ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x56, 0x4, 0xcc), 0xc000076ca8) = -1 ENOTTY (Inappropriate ioctl for device)
write(1, "failed to get pix format\n", 25failed to get pix format
It looks like encoded command is not VIDIOC_G_FMT
and is not recognized by kernel.
package main
import (
"fmt"
"github.com/vladimirvivien/go4vl/v4l2"
)
func main() {
device, err := v4l2.Open("/dev/video0")
if err != nil {
panic(err)
}
_, err = device.GetPixFormat()
if err != nil {
fmt.Println("failed to get pix format")
panic(err)
}
}
My kernel is
Linux endless 5.14.14-arch1-1 #1 SMP PREEMPT Wed, 20 Oct 2021 21:35:18 +0000 x86_64 GNU/Linux
Cause
I don't think this problem is caused by kernel.
I can use <linux/videodev2.h> and it does not cause this error
With the C API I get
ioctl(3, VIDIOC_G_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=1280, height=720, pixelformat=v4l2_fourcc('M', 'J', 'P', 'G') /* V4L2_PIX_FMT_MJPEG */, field=V4L2_FIELD_NONE, bytesperline=0, sizeimage=1843200, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
It looks like the problem is caused in ioctl encoding functions. I rechecked the ioct.go but could not find the problem