首页 > 解决方案 > 来自两个摄像头的 ffmpeg 流视频具有相同的设备名称

问题描述

有两个相机具有相同的设备名称Microsoft® LifeCam Studio(TM)
ffmpeg -list_deivces true -f dshow -i dummy打印以下输出。

C:\Users\user>ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version git-2020-02-05-e6891d1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 39.100 / 56. 39.100
  libavcodec     58. 67.101 / 58. 67.101
  libavformat    58. 37.100 / 58. 37.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 74.100 /  7. 74.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[dshow @ 000001d5c5108dc0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000001d5c5108dc0]  "Microsoft® LifeCam Studio(TM)"
[dshow @ 000001d5c5108dc0]     Alternative name "@device_pnp_\\?\usb#vid_045e&pid_0811&mi_00#8&6ae46e6&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000001d5c5108dc0]  "Microsoft® LifeCam Studio(TM)"
[dshow @ 000001d5c5108dc0]     Alternative name "@device_pnp_\\?\usb#vid_045e&pid_0811&mi_00#8&e544916&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000001d5c5108dc0] DirectShow audio devices
[dshow @ 000001d5c5108dc0]  "Desktop Microphone (6- Microsoft® LifeCam Studio(TM))"
[dshow @ 000001d5c5108dc0]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{D5F4881A-6E88-4563-8BA0-081CFD50E353}"
[dshow @ 000001d5c5108dc0]  "Desktop Microphone (5- Microsoft® LifeCam Studio(TM))"
[dshow @ 000001d5c5108dc0]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{84674B28-DC68-4AC0-8331-D687C7B7D69C}"
[dshow @ 000001d5c5108dc0]  "Digital Audio (S/PDIF) (High Definition Audio Device)"
[dshow @ 000001d5c5108dc0]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{CDD24485-59D2-4BED-B6FC-B7447251C7E2}"

因为两个摄像头具有相同的设备名称,我无法同时使用这个简单的命令流式传输两个视频:ffplay -f dshow -i video=Microsoft® LifeCam Studio(TM).
所以我在ffmpeg dshow 示例之后使用了引脚名称。我唯一能检查的是Could not find video device with name [video=~~pin name~~] among source devices of type video.

什么ffplay命令可以流式传输两个视频?

标签: ffmpegdirectshow

解决方案


我用这些便宜的 HDMI 捕获 USB 加密狗遇到了同样的情况。仔细阅读答案在页面上:http: //ffmpeg.org/ffmpeg-devices.html#dshow

同名 dshow 设备由 ffmepg 索引。在 Windows 中,在“-f dshow”和“-i”设备名称之间添加“-video_device_number xxx”。其他平台的开关名称不同,但语法非常相似。

ffmpeg -f dshow -video_device_number 0 -i video="USB Video" ....

推荐阅读