使用 V4L2 选择输入通道 API
Choosing input channel with V4L2 API
我想选择我的 VideoCamera 设备的输入通道。我可以通过 "Settings-Dialog" 在 VLC 中 select 它。在高级设置中,我可以将 'input' 切换为 3,并且我的相机可以正常工作。
现在我想在我的 C++ 应用程序中执行此操作。我找不到执行此操作的写入方法。目前我的照片是黑色的。我需要为我的设备选择 S-Video 频道。
你应该看看 v4l2-ctl
的源代码,它是 v4l-utils. This tool is written in C++/Qt and should provide you with all information you need to do it yourself. Changing the input for a device is handled in v4l2-ctl-io.cpp
的一部分
void io_set(int fd)
{
if (options[OptSetInput]) {
if (doioctl(fd, VIDIOC_S_INPUT, &input) == 0) {
struct v4l2_input vin;
printf("Video input set to %d", input);
vin.index = input;
if (test_ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0)
printf(" (%s: %s)", vin.name, status2s(vin.status).c_str());
printf("\n");
}
}
// snip...
}
希望对您有所帮助。
编辑:
刚刚在官方 API 文档 here 中找到了相关部分。
他们在该页面上有一些示例如何更改视频输入。
我想选择我的 VideoCamera 设备的输入通道。我可以通过 "Settings-Dialog" 在 VLC 中 select 它。在高级设置中,我可以将 'input' 切换为 3,并且我的相机可以正常工作。 现在我想在我的 C++ 应用程序中执行此操作。我找不到执行此操作的写入方法。目前我的照片是黑色的。我需要为我的设备选择 S-Video 频道。
你应该看看 v4l2-ctl
的源代码,它是 v4l-utils. This tool is written in C++/Qt and should provide you with all information you need to do it yourself. Changing the input for a device is handled in v4l2-ctl-io.cpp
void io_set(int fd)
{
if (options[OptSetInput]) {
if (doioctl(fd, VIDIOC_S_INPUT, &input) == 0) {
struct v4l2_input vin;
printf("Video input set to %d", input);
vin.index = input;
if (test_ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0)
printf(" (%s: %s)", vin.name, status2s(vin.status).c_str());
printf("\n");
}
}
// snip...
}
希望对您有所帮助。
编辑: 刚刚在官方 API 文档 here 中找到了相关部分。 他们在该页面上有一些示例如何更改视频输入。