blackjack / webcam

Golang webcam library for Linux
MIT License
411 stars 90 forks source link

WaitForFrame times out on RPi (with LifeCam and RPi internal camera) #34

Open mms- opened 4 years ago

mms- commented 4 years ago

On RPi3 with Ubuntu/arm64 with a Microsoft Studio webcam always times out on cam.WaitForFrame(..) call when using YUYV 4:2:2 and 1920x1080 while 640x480 works just fine. However MJPEG works fine at 1920x1080. No other errors just a timeout. Potential there is a buffer issue somewhere since the amount of data with YUY will be much higher?

However MJPEG also fails. A different RPi with Raspbian and an internal RPi Cam getting the following trace:

DeviceConfig: /dev/video0, Motion-JPEG, Available formats: Planar YVU 4:2:0, 32-bit BGRA/X 8-8-8-8, H.264, UYVY 4:2:2, Y/CbCr 4:2:0, VYUY 4:2:2, YUYV 4:2:2, 24-bit RGB 8-8-8, JFIF JPEG, Motion-JPEG, YVYU 4:2:2, Y/CrCb 4:2:0, Planar YUV 4:2:0, 24-bit BGR 8-8-8, Supported frame sizes for format: Motion-JPEG [32-3280;2]x[32-2464;2], Request: Motion-JPEG [32-3280;2]x[32-2464;2] Result: Motion-JPEG 3280x2464 Wait frame.. Webcam wait frame, retrying: Timeout occured Wait frame.. Webcam wait frame, retrying: Timeout occured Wait frame..

The timeout is at 10sec but I have tried minutes and it never yields data same when trying YUYV Is this normal? What could the issue be?

Also a Logitech Brio has the same issue, timeout on WaitForFrame.

jackfong66 commented 4 years ago

rmmod bcm2835-v4l2 modprobe bcm2835-v4l2 Destroys and re-creates /dev/video0

I replaced the resolution with 640 * 480 without problems pi zero W. CSI is OK

tobearlabs commented 4 years ago

With my raspicam i get always streaming:operation not permitted - any ideas? (also with sudo). If i attach a usb webcam everything works fine.

pojntfx commented 3 years ago

I have the same problem as @tobearlabs - Pi Zero WH, Pi ZeroCam..

pojntfx commented 3 years ago

Fixed it! This happens because the Zero is to slow to handle high-resolution video streams. Using f, w, h, err := cam.SetImageFormat(format, uint32(size.MinWidth), uint32(size.MaxWidth)) instead of f, w, h, err := cam.SetImageFormat(format, uint32(size.MaxWidth), uint32(size.MaxHeight)) for example https://github.com/blackjack/webcam/blob/master/examples/stdout_streamer/stdout_streamer.go works.