列出可用于gstreamer 1.0中的ksvideosrc的视频捕获的设备名称 [英] List device-names available for video capture from ksvideosrc in gstreamer 1.0

查看:1062
本文介绍了列出可用于gstreamer 1.0中的ksvideosrc的视频捕获的设备名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c ++中的gstreamer 1.0查询可用的视频捕获设备(网络摄像头)列表。

I am trying to query a list of available video capture devices (webcams) on windows using gstreamer 1.0 in c++.

我使用ksvideosrc作为源,能够捕获视频输入,但我无法查询可用设备(及其上限)的列表。

I am using ksvideosrc as source and i am able to capture the video input but i can't query a list of available devices (and their caps).

在gstreamer 0.10上,可以通过GstPropertyProbe删除在gstreamer 1.0。文档建议使用GstDeviceMonitor。但我没有运气使用这个。

On gstreamer 0.10 it has been possible through GstPropertyProbe which is removed in gstreamer 1.0. The documentation suggests using GstDeviceMonitor. But i have no luck using that either.

有没有人成功地获取设备名称的列表?

Has anyone succeeded in acquiring a list of device names? Or can you suggests another way of retrieving the available device names and their caps?

推荐答案

虽然我还没有想出如何使用设备名称,枚举设备名称,我想出了一个解决方法,至少获得可用的 ksvideosrc 设备索引。下面是Python中的代码,但是你应该能够很容易地将它移植到C ++,感谢GObject内省绑定。

Although I haven't figured out how to enumerate the device names, I've come up with a workaround to at least get the available ksvideosrc device indexes. Below is the code in Python, but you should be able to port it to C++ fairly easily, thanks to the GObject introspection bindings.

from gi.repository import Gst


def get_ksvideosrc_device_indexes():
    device_index = 0
    video_src = Gst.ElementFactory.make('ksvideosrc')
    state_change_code = None

    while True:
        video_src.set_state(Gst.State.NULL)
        video_src.set_property('device-index', device_index)
        state_change_code = video_src.set_state(Gst.State.READY)
        if state_change_code != Gst.StateChangeReturn.SUCCESS:
            video_src.set_state(Gst.State.NULL)
            break
        device_index += 1
    return range(device_index)


if __name__ == '__main__':
    Gst.init()
    print get_ksvideosrc_device_indexes()

请注意,视频来源 device-name 无从 ksvideosrc 的GStreamer版本1.4.5.0开始。

Note that the video source device-name property is None as of GStreamer version 1.4.5.0 on Windows for the ksvideosrc.

这篇关于列出可用于gstreamer 1.0中的ksvideosrc的视频捕获的设备名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆