V4L problem with VIDIOCGCAP ioctl call
Question
I'm having some issue working with V4L (the API that provides unified access to various video capturing for Linux). I'm tryng to make a VIDIOCGCAP ioctl call, but I get an INVALID ARGUMENT error. Here is an strace:
execve("./test", ["./test"], [/* 26 vars */]) = 0 brk(0) = 0x8d5c000 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=29703, ...}) = 0 mmap2(NULL, 29703, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fc1000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/i686/cmov/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1\0004\0\0\0\4"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0755, st_size=1413540, ...}) = 0 mmap2(NULL, 1418864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e66000 mmap2(0xb7fbb000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x155) = 0xb7fbb000 mmap2(0xb7fbe000, 9840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7fbe000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e65000 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e656b0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 mprotect(0xb7fbb000, 4096, PROT_READ) = 0 munmap(0xb7fc1000, 29703) = 0 open("/dev/video0", O_RDONLY) = 3 ioctl(3, EXT2_IOC_GETVERSION or VIDIOCGCAP, 0xbf8e4ca4) = -1 EINVAL (Invalid argument) fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc8000 write(1, "err"..., 3err) = 3 exit_group(3) = ? = ?
Here is the code:
#include "linux/videodev.h" #include "fcntl.h" #include "stdio.h" int main() { int fd = open("/dev/video0", O_RDONLY); struct video_capability chan; if (ioctl(fd, VIDIOCGCAP, &chan) == -1) printf("err"); }
And:
gcc -o test test.c
More info: I have other video capture software in this machine that use V4L without problems. So, I'm doing something wrong.
Solution
Perhaps you need to try using V4L2 instead, namely the VIDIOC_QUERYCAP ioctl.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow