1

我在使用 V4L(为 Linux 提供对各种视频捕获的统一访问的 API)时遇到了一些问题。我正在尝试进行 VIDIOCGCAP ioctl 调用,但收到 INVALID ARGUMENT 错误。这是一个strace:

execve("./test", ["./test"], [/* 26 vars */]) = 0
brk(0) = 0x8d5c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (没有那个文件或目录)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (没有这样的文件或目录)
打开(“/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
关闭(3)= 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (没有那个文件或目录)
打开(“/lib/i686/cmov/libc.so.6”,O_RDONLY)= 3
读(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
关闭(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
打开(“/dev/video0”,O_RDONLY)= 3
ioctl(3, EXT2_IOC_GETVERSION 或 VIDIOCGCAP, 0xbf8e4ca4) = -1 EINVAL(无效参数)
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
写(1,“错误”...,3err)= 3
退出组(3)=?= ?

这是代码:

#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");
}

和:

gcc -o 测试 test.c

更多信息:我在这台机器上有其他使用 V4L 没有问题的视频捕获软件。所以,我做错了什么。

4

1 回答 1

2

也许您需要尝试使用 V4L2,即 VIDIOC_QUERYCAP ioctl。

于 2009-05-22T17:25:47.037 回答