【问题标题】:How can I get the name of the webcams present on the computer in python?如何在 python 中获取计算机上存在的网络摄像头的名称?
【发布时间】:2021-07-07 17:08:21
【问题描述】:

我有问题。 我需要在 python 中使用带有子进程的 ffmpeg 进行视频捕获。

为此,我需要识别计算机中存在的摄像头的名称,以便能够将此参数传递给 ffmpeg 进程。

目前我已经使用了WMI模块,但是它只适用于windows,不太好用。

有没有更简单的方法来提取计算机上网络摄像头的名称并将它们保存到数组中? 也许还使用 ffmpeg list-devices 并过滤结果? 你能帮帮我吗?

我不想再使用 WMI 模块,因为我想要一个适用于 windows 或 linux 的通用解决方案,可能使用 subprocess 和 ffmpeg list_devices 命令。 谢谢

【问题讨论】:

    标签: python ffmpeg subprocess webcam


    【解决方案1】:

    窗口

    在 Windows 中使用 dshow:

    ffmpeg -list_devices true -f dshow -i dummy
    

    Linux

    在 Linux 中使用 v4l2-ctl:

    v4l2-ctl --list-devices
    

    然后使用FFmpeg video4linux2/v4l2 demuxer 连接。

    另见

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多