2017-09-16 164 views
0

我想從外部usb cam上的樹莓pi 3上保存視頻。爲了避免電壓降問題,我使用官方的樹莓派電源(2.5 A)和由separetely供電的USB集線器連接所有的USB設備:使用ffmpeg在usb cam上錄製usb cam - usb故障排除

[email protected]:~/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凸輪已經被重置了:

[email protected]:~/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消失:

[email protected]:~/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通信問題?

回答