使用 ffmpeg 在 raspberry pi 上录制 usb cam - usb 故障排除

Recording usb cam on raspberry pi with ffmpeg - usb troubleshooting

我想在 raspberry pi 上保存来自外部 USB 摄像头的视频 3. 为了避免电压下降问题,我使用官方树莓派电源(2.5 安培)并通过一个连接所有 USB 设备单独供电的 USB 集线器:

pi@raspi:~/appdev/ffmpeg $ lsusb
Bus 001 Device 037: ID 046d:09a1 Logitech, Inc. QuickCam Communicate MP/S5500
Bus 001 Device 036: ID 046d:c03f Logitech, Inc. M-BT85 [UltraX Optical Mouse]
Bus 001 Device 035: ID 04d9:1503 Holtek Semiconductor, Inc. Shortboard Lefty
Bus 001 Device 012: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

当我尝试通过 运行 以下 bash 脚本(片段)测试功能时:

function capture
{
    capfile=$(date +%F_%Hh%Mm%Ss)
    echo saving to $wdir/$capfile.mp4
    echo $PATH
    ffmpeg -video_size 320x240 -i /dev/video0 \
    -vf drawtext="fontsize=18:x=10:y=220:fontcolor=red:\
    fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:\
    text=%{localtime}" -t 10 $wdir/$capfile.mp4
    # change -t to 3600 = 1h
}

for i in $(seq 1 10)
do
    echo
    echo Pass $i ...
    capture
done

循环运行几次后,我总是看到设备错误:

Pass 5 ...
saving to /home/pi/appdev/ffmpeg/2017-09-16_13h31m00s.mp4
/usr/local/bin:/usr/bin/ffmpeg:/usr/bin:/bin:/sbin
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --arch=armhf --target-os=linux --enable-gpl --enable-libfreetype --enable-mmal --enable-nonfree --enable-omx --enable-omx-rpi
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
/dev/video0: Input/output error

内核消息日志显示USB摄像头已被重置:

pi@raspi:~/appdev/ffmpeg $ dmesg | grep usb
[ 4497.358195] usb 1-1.2.4: new high-speed USB device number 37 using dwc_otg
[ 4497.573440] usb 1-1.2.4: New USB device found, idVendor=046d, idProduct=09a1
[ 4497.573466] usb 1-1.2.4: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[ 4497.573481] usb 1-1.2.4: SerialNumber: A032D310
[ 4497.605698] input: UVC Camera (046d:09a1) as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0/input/input15
[ 4497.625582] usb 1-1.2.4: Warning! Unlikely big volume range (=3072), cval->res is probably wrong.
[ 4497.625606] usb 1-1.2.4: [5] FU [Mic Capture Volume] ch = 1, val = 4608/7680/1
[ 5268.123764] usb 1-1.2.4: reset high-speed USB device number 37 using dwc_otg

下次我启动脚本时,USB 摄像头断开连接并且 /dev/viedo0 消失:

pi@raspi:~/appdev/ffmpeg $ dmesg | grep usb
[ 5621.216896] usb 1-1.2.4: USB disconnect, device number 37
[ 5621.586804] usb 1-1.2.4: new full-speed USB device number 38 using dwc_otg
[ 5621.686694] usb 1-1.2.4: device descriptor read/64, error -32
[ 5621.896583] usb 1-1.2.4: device descriptor read/64, error -32
[ 5622.106572] usb 1-1.2.4: new full-speed USB device number 39 using dwc_otg
[ 5622.206574] usb 1-1.2.4: device descriptor read/64, error -32
[ 5622.416577] usb 1-1.2.4: device descriptor read/64, error -32
[ 5622.626586] usb 1-1.2.4: new full-speed USB device number 40 using dwc_otg
[ 5623.046583] usb 1-1.2.4: device not accepting address 40, error -32
[ 5623.146583] usb 1-1.2.4: new full-speed USB device number 41 using dwc_otg
[ 5623.566603] usb 1-1.2.4: device not accepting address 41, error -32
[ 5623.566670] usb 1-1.2-port4: unable to enumerate USB device

有没有人遇到过类似的问题并且可以提供解决方案?

我可以使用什么工具来解决 pi 上的 usb 通信问题?

我通过对 /boot/cmdline.txt 进行以下编辑得到它 运行: dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0x3

来源: https://volumio.org/forum/solution-pops-and-clicks-t772.html