vladimirvivien / go4vl

A Go library for working with the Video for Linux API (V4L2).
MIT License
245 stars 45 forks source link

Buffer dequeue error #14

Closed IanPhilips closed 2 years ago

IanPhilips commented 2 years ago

Hi,

I'm testing out the mjpeg saving example in the README (making the sole change of width to 1280 and height to 720 - which the camera DOES support) and half of the time the example runs smoothly and then sometimes when I run it I get the following error:

Done.
panic: device: capture: buffer dequeue: system error

goroutine 34 [running]:
github.com/vladimirvivien/go4vl/v4l2.(*Device).Capture.func1(0xd06000, 0x3, 0xcb0850, {0x104658, 0xd02000}, 0x1fca055)
    /home/pi/go/pkg/mod/github.com/vladimirvivien/go4vl@v0.0.1/v4l2/device.go:245 +0x3c0
created by github.com/vladimirvivien/go4vl/v4l2.(*Device).Capture
    /home/pi/go/pkg/mod/github.com/vladimirvivien/go4vl@v0.0.1/v4l2/device.go:230 +0xd0
exit status 2

Have you seen that before or have any idea why it might be happening seemingly randomly?

Thanks for the library btw!

vladimirvivien commented 2 years ago

Thanks @IanPhilips for checking out the project. I don't think I have seen this error before. I started putting a bug label on this issue, but after I read the output, it seems that it's a system error. It's possible that the initial buffer size is not proper or invalid for the device. The V4L2 API is an intricate beast and can require subtle coding to handle all corner cases. I know these examples don't do a good job at that. Nevertheless, I will keep an eye on that.

IanPhilips commented 2 years ago

Thanks for the quick response! It's weird because the example code completes its job of saving the frames just fine, and then upon exiting & stopping the stream, that error comes up.

IanPhilips commented 2 years ago

Hmmmm actually it seems like all the example needs is a os.Exit(0) at the end to avoid the error! I haven't used go in a while though and am not sure if that's a valid solution. If so I can submit a PR for that fix.

vladimirvivien commented 2 years ago

I am closing this for now. If there are still issues, please re-open.