Raspberry PI에서 2개의 동일한 카메라를 사용하여 동시에 비디오 녹화

Raspberry PI에서 2개의 동일한 카메라를 사용하여 동시에 비디오 녹화

동일한 USB 카메라 2대를 사용하여 Raspberry Pi 4 1GB(Raspbian 10)에 동영상을 녹화하고 싶습니다. 두 카메라 모두 VID:PID( )와 일련 번호(SN5100)가 동일하므로 05a3:9530주어진 시간에 카메라 중 하나만 비디오를 녹화합니다.

같이 사진을 찍으면 기분이 이상할 것 같아요.

fswebcam -d /dev/video0

또는

fswebcam -d /dev/video2

항상 올바른 카메라로 사진을 찍습니다. 따라서 운영 체제나 USB 컨트롤러는 이를 처리할 수 있는 다른 방법이 있어야 합니다.

두 카메라가 모두 연결되어 있는 경우분리내 컴퓨터에는 USB 컨트롤러가 있고 동시에 비디오를 녹화합니다. 그러나 RPi에는 이 옵션이 없습니다.

내가 시도한 것:

  • OBS에 두 대의 카메라 추가 - 처음 추가된 카메라만 작동
  • MotionEye와 함께 사용 - OBS와 동일
  • 2개의 서로 다른 USB 카메라 사용 - 두 카메라가 동시에 작동하지만 안타깝게도 이 해결 방법으로 문제가 해결되지 않았습니다.

  • ffmpeg를 사용하여 카메라에서 스트림을 재생합니다.

ffplay -f video4linux2 -i /dev/video0

그리고

ffplay -f video4linux2 -i /dev/video2

첫 번째 카메라는 정상적으로 재생되고 두 번째 카메라는 터미널에 출력됩니다.

nan: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0KB f= 0/0

첫 번째 스트림이 종료되면 두 번째 카메라가 즉시 작동을 시작합니다.

  • 내가 관리하는 USB 포트에 연결했을 때 시도한 모든 컴퓨터에서 문제가 지속됩니다.동일한USB 컨트롤러
  • USB 허브 사용
  • 새 PID 작성 중 sys/bus/usb/devices/1-1.4/idProduct- 파일을 쓸 수 없음

  • 1개의 USB 포트에 대한 사용자 정의 udev 규칙을 추가하고 이름을 변경하거나 심볼릭 링크를 추가하십시오.

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==""

두 번째 카메라의 경우:

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==""

동시에 영상을 녹화할 수 있는 방법이 있나요?

답변1

Hermann이 댓글에서 언급했듯이 두 대의 USB 카메라에서 스트리밍 비디오는 다음을 통해 달성됩니다.

  • FFMPEG:
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

둘 다-픽셀 형식그리고-비디오 크기v4l2-ctl --list-formats-ext출력의 조합 이어야 합니다 .v4l2-ctl -d /dev/video0 (or other device) --list-formats-ext

관련 정보