2つの同一のUSBカメラを使用して、Raspberry Pi 4 1GB(Raspbian 10)でビデオを録画したい。両方のカメラのVID:PID(05a3:9530
)とシリアル番号(SN5100)なので、常に1つだけがビデオを録画します。
彼らと一緒に写真を撮った場合、私にとって奇妙なことは何ですか。
fswebcam -d /dev/video0
または
fswebcam -d /dev/video2
常に正しいカメラで写真を撮ります。したがって、OSまたはUSBコントローラーがそれらに対処する別の方法が必要です。
両方のカメラが私のPCに接続されている場合個別のUSBコントローラー、両方が同時にビデオを記録します。ただし、RPiにはそのオプションはありません。
私が試したこと:
2つの異なるUSBカメラを使用-両方が同時に動作しますが、残念ながらこの回避策は私の問題の解決策ではありません
カメラからのストリームをffmpegで再生する:
ffplay -f video4linux2 -i /dev/video0
そして
ffplay -f video4linux2 -i /dev/video2
最初のものはOKを再生し、2番目のカメラはターミナルに出力します。
nan: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0KB f= 0/0
最初のストリームを終了すると、2番目のカメラが即座に動作を開始します。
sys/bus/usb/devices/1-1.4/idProduct
新しいPID-ファイルは書き込み不可
1つのUSBポートのカスタムudevルールを追加して、NAMEを変更するか、SYMLINKを追加します。
KERNEL=="1-1.4", NAME="device_1_4"
または
KERNEL=="1-1.4", SYMLINK+="device_1_4"
以下からの出力に基づいてそれらを区別する他の方法がないことに注意してください:
udevadm info --attribute-walk --path=/sys/bus/usb/devices/1-1.4
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4':
KERNEL=="1-1.4"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{manufacturer}=="Sonix Technology Co., Ltd."
ATTR{maxchild}=="0"
ATTR{idVendor}=="05a3"
ATTR{bNumInterfaces}==" 2"
ATTR{authorized}=="1"
ATTR{bMaxPacketSize0}=="64"
ATTR{devpath}=="1.4"
ATTR{bNumConfigurations}=="1"
ATTR{configuration}==""
ATTR{removable}=="unknown"
ATTR{urbnum}=="55639"
ATTR{rx_lanes}=="1"
ATTR{bmAttributes}=="80"
ATTR{version}==" 2.00"
ATTR{idProduct}=="9530"
ATTR{serial}=="SN5100"
ATTR{bDeviceSubClass}=="02"
ATTR{bDeviceClass}=="ef"
ATTR{bDeviceProtocol}=="01"
ATTR{product}=="USB 2.0 Camera"
ATTR{devspec}==" (null)"
ATTR{avoid_reset_quirk}=="0"
ATTR{ltm_capable}=="no"
ATTR{devnum}=="11"
ATTR{bMaxPower}=="256mA"
ATTR{quirks}=="0x0"
ATTR{tx_lanes}=="1"
ATTR{speed}=="480"
ATTR{bcdDevice}=="0100"
ATTR{bConfigurationValue}=="1"
ATTR{busnum}=="1"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{busnum}=="1"
ATTRS{bDeviceSubClass}=="00"
ATTRS{speed}=="480"
ATTRS{urbnum}=="455"
ATTRS{product}=="USB2.0 Hub"
ATTRS{quirks}=="0x0"
ATTRS{devspec}==" (null)"
ATTRS{bMaxPower}=="100mA"
ATTRS{ltm_capable}=="no"
ATTRS{idProduct}=="3431"
ATTRS{idVendor}=="2109"
ATTRS{bNumInterfaces}==" 1"
ATTRS{maxchild}=="4"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bNumConfigurations}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{tx_lanes}=="1"
ATTRS{devnum}=="2"
ATTRS{removable}=="unknown"
ATTRS{bcdDevice}=="0421"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{configuration}==""
ATTRS{version}==" 2.10"
ATTRS{rx_lanes}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{devpath}=="1"
ATTRS{authorized}=="1"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{speed}=="480"
ATTRS{idProduct}=="0002"
ATTRS{maxchild}=="1"
ATTRS{bcdDevice}=="0419"
ATTRS{devnum}=="1"
ATTRS{tx_lanes}=="1"
ATTRS{manufacturer}=="Linux 4.19.97-v7l+ xhci-hcd"
ATTRS{idVendor}=="1d6b"
ATTRS{bMaxPower}=="0mA"
ATTRS{removable}=="unknown"
ATTRS{product}=="xHCI Host Controller"
ATTRS{busnum}=="1"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bNumInterfaces}==" 1"
ATTRS{serial}=="0000:01:00.0"
ATTRS{authorized}=="1"
ATTRS{authorized_default}=="1"
ATTRS{bNumConfigurations}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{devspec}==" (null)"
ATTRS{version}==" 2.00"
ATTRS{bDeviceClass}=="09"
ATTRS{urbnum}=="201"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bConfigurationValue}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{ltm_capable}=="no"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{devpath}=="0"
ATTRS{rx_lanes}=="1"
ATTRS{interface_authorized_default}=="1"
ATTRS{configuration}==""
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0':
KERNELS=="0000:01:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="xhci_hcd"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{local_cpus}=="f"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{devspec}==""
ATTRS{dma_mask_bits}=="64"
ATTRS{device}=="0x3483"
ATTRS{max_link_width}=="1"
ATTRS{class}=="0x0c0330"
ATTRS{driver_override}=="(null)"
ATTRS{irq}=="54"
ATTRS{ari_enabled}=="0"
ATTRS{subsystem_device}=="0x3483"
ATTRS{msi_bus}=="1"
ATTRS{vendor}=="0x1106"
ATTRS{subsystem_vendor}=="0x1106"
ATTRS{revision}=="0x01"
ATTRS{current_link_width}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{current_link_speed}=="5 GT/s"
ATTRS{max_link_speed}=="5 GT/s"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0':
KERNELS=="0000:00:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="pcieport"
ATTRS{max_link_speed}=="5 GT/s"
ATTRS{broken_parity_status}=="0"
ATTRS{subsystem_vendor}=="0x0000"
ATTRS{aer_rootport_total_err_cor}=="0"
ATTRS{max_link_width}=="1"
ATTRS{current_link_width}=="1"
ATTRS{secondary_bus_number}=="1"
ATTRS{driver_override}=="(null)"
ATTRS{vendor}=="0x14e4"
ATTRS{class}=="0x060400"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{irq}=="53"
ATTRS{device}=="0x2711"
ATTRS{subsystem_device}=="0x0000"
ATTRS{subordinate_bus_number}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{msi_bus}=="1"
ATTRS{devspec}==""
ATTRS{current_link_speed}=="5 GT/s"
ATTRS{aer_rootport_total_err_fatal}=="0"
ATTRS{local_cpus}=="f"
ATTRS{ari_enabled}=="0"
ATTRS{revision}=="0x10"
ATTRS{aer_rootport_total_err_nonfatal}=="0"
ATTRS{dma_mask_bits}=="32"
ATTRS{enable}=="1"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
looking at parent device '/devices/platform/scb/fd500000.pcie':
KERNELS=="fd500000.pcie"
SUBSYSTEMS=="platform"
DRIVERS=="brcm-pcie"
ATTRS{dmabounce_stats}=="m:0/0 s:0/0 f:0 s:0 b:0/0 a:0/0"
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform/scb':
KERNELS=="scb"
SUBSYSTEMS=="platform"
DRIVERS==""
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
そして2番目のカメラ:
udevadm info --attribute-walk --path=/sys/bus/usb/devices/1-1.1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1':
KERNEL=="1-1.1"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{devspec}==" (null)"
ATTR{urbnum}=="146921"
ATTR{tx_lanes}=="1"
ATTR{configuration}==""
ATTR{speed}=="480"
ATTR{bNumInterfaces}==" 2"
ATTR{manufacturer}=="Sonix Technology Co., Ltd."
ATTR{bDeviceProtocol}=="01"
ATTR{devpath}=="1.1"
ATTR{busnum}=="1"
ATTR{bcdDevice}=="0100"
ATTR{bMaxPower}=="256mA"
ATTR{version}==" 2.00"
ATTR{serial}=="SN5100"
ATTR{bDeviceClass}=="ef"
ATTR{bConfigurationValue}=="1"
ATTR{product}=="USB 2.0 Camera"
ATTR{idProduct}=="9530"
ATTR{avoid_reset_quirk}=="0"
ATTR{idVendor}=="05a3"
ATTR{bNumConfigurations}=="1"
ATTR{bDeviceSubClass}=="02"
ATTR{rx_lanes}=="1"
ATTR{authorized}=="1"
ATTR{maxchild}=="0"
ATTR{removable}=="unknown"
ATTR{bMaxPacketSize0}=="64"
ATTR{ltm_capable}=="no"
ATTR{bmAttributes}=="80"
ATTR{devnum}=="9"
ATTR{quirks}=="0x0"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{quirks}=="0x0"
ATTRS{bmAttributes}=="e0"
ATTRS{tx_lanes}=="1"
ATTRS{devnum}=="2"
ATTRS{configuration}==""
ATTRS{authorized}=="1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPower}=="100mA"
ATTRS{product}=="USB2.0 Hub"
ATTRS{idProduct}=="3431"
ATTRS{idVendor}=="2109"
ATTRS{busnum}=="1"
ATTRS{devpath}=="1"
ATTRS{urbnum}=="473"
ATTRS{bcdDevice}=="0421"
ATTRS{removable}=="unknown"
ATTRS{maxchild}=="4"
ATTRS{speed}=="480"
ATTRS{bNumConfigurations}=="1"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devspec}==" (null)"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{rx_lanes}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{bNumInterfaces}==" 1"
ATTRS{version}==" 2.10"
ATTRS{avoid_reset_quirk}=="0"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{tx_lanes}=="1"
ATTRS{product}=="xHCI Host Controller"
ATTRS{rx_lanes}=="1"
ATTRS{bMaxPower}=="0mA"
ATTRS{idVendor}=="1d6b"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bConfigurationValue}=="1"
ATTRS{authorized_default}=="1"
ATTRS{urbnum}=="210"
ATTRS{devpath}=="0"
ATTRS{bmAttributes}=="e0"
ATTRS{ltm_capable}=="no"
ATTRS{idProduct}=="0002"
ATTRS{bDeviceClass}=="09"
ATTRS{configuration}==""
ATTRS{version}==" 2.00"
ATTRS{bcdDevice}=="0419"
ATTRS{serial}=="0000:01:00.0"
ATTRS{busnum}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{devnum}=="1"
ATTRS{manufacturer}=="Linux 4.19.97-v7l+ xhci-hcd"
ATTRS{bDeviceProtocol}=="01"
ATTRS{speed}=="480"
ATTRS{authorized}=="1"
ATTRS{devspec}==" (null)"
ATTRS{interface_authorized_default}=="1"
ATTRS{quirks}=="0x0"
ATTRS{maxchild}=="1"
ATTRS{removable}=="unknown"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bNumConfigurations}=="1"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0':
KERNELS=="0000:01:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="xhci_hcd"
ATTRS{class}=="0x0c0330"
ATTRS{current_link_speed}=="5 GT/s"
ATTRS{msi_bus}=="1"
ATTRS{revision}=="0x01"
ATTRS{vendor}=="0x1106"
ATTRS{driver_override}=="(null)"
ATTRS{max_link_width}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{devspec}==""
ATTRS{dma_mask_bits}=="64"
ATTRS{ari_enabled}=="0"
ATTRS{enable}=="1"
ATTRS{irq}=="54"
ATTRS{subsystem_vendor}=="0x1106"
ATTRS{device}=="0x3483"
ATTRS{max_link_speed}=="5 GT/s"
ATTRS{current_link_width}=="1"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{subsystem_device}=="0x3483"
ATTRS{local_cpus}=="f"
ATTRS{local_cpulist}=="0-3"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0':
KERNELS=="0000:00:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="pcieport"
ATTRS{revision}=="0x10"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{irq}=="53"
ATTRS{subsystem_device}=="0x0000"
ATTRS{msi_bus}=="1"
ATTRS{max_link_width}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{enable}=="1"
ATTRS{subordinate_bus_number}=="1"
ATTRS{subsystem_vendor}=="0x0000"
ATTRS{current_link_width}=="1"
ATTRS{driver_override}=="(null)"
ATTRS{device}=="0x2711"
ATTRS{aer_rootport_total_err_cor}=="0"
ATTRS{ari_enabled}=="0"
ATTRS{local_cpus}=="f"
ATTRS{class}=="0x060400"
ATTRS{max_link_speed}=="5 GT/s"
ATTRS{dma_mask_bits}=="32"
ATTRS{aer_rootport_total_err_nonfatal}=="0"
ATTRS{local_cpulist}=="0-3"
ATTRS{current_link_speed}=="5 GT/s"
ATTRS{aer_rootport_total_err_fatal}=="0"
ATTRS{secondary_bus_number}=="1"
ATTRS{devspec}==""
ATTRS{vendor}=="0x14e4"
looking at parent device '/devices/platform/scb/fd500000.pcie/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
looking at parent device '/devices/platform/scb/fd500000.pcie':
KERNELS=="fd500000.pcie"
SUBSYSTEMS=="platform"
DRIVERS=="brcm-pcie"
ATTRS{driver_override}=="(null)"
ATTRS{dmabounce_stats}=="m:0/0 s:0/0 f:0 s:0 b:0/0 a:0/0"
looking at parent device '/devices/platform/scb':
KERNELS=="scb"
SUBSYSTEMS=="platform"
DRIVERS==""
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
両方を同時に録画する方法はありますか?
Hermannのコメントで述べたように、両方のUSBカメラからのビデオのストリーミングは、次の方法で可能になりました。
ffplay -f v4l2 -pixel_format mjpeg -video_size 1280x720 -framerate 30 -i /dev/video0
そして
ffplay -f v4l2 -pixel_format mjpeg -video_size 1280x720 -framerate 30 -i /dev/video2
-pixel_formatと-video_sizeは、v4l2-ctl --list-formats-ext
出力またはv4l2-ctl -d /dev/video0 (or other device) --list-formats-ext