use libv4l2 (https://github.com/philips/libv4l) for local USB cameras .#3733
use libv4l2 (https://github.com/philips/libv4l) for local USB cameras .#3733sletteland wants to merge 5 commits intoZoneMinder:masterfrom
Conversation
This allows very simple/primitive cameras to work out of the box . (like USB cameras using the gspca driver )
|
This is straight forward enough. My understand in the past was that we could load v4l2 at runtime but I never got it to work. So perhaps this is the way to go. We will need to add the lib to the package dependencies as well. I am going to have to dig up my lego cam to see if this allows it to work! |
|
I think my issue with this is... it makes v4l2 a requirement... it should fall back to not using v4l2. So I'm not opposed to this, but we need #else conditions |
|
Hi Isaac
Thanks for answering my patch request .
however , this was in 2023 ..
we are now in 2025 . Water has gone under bridges since , and i
completely forgot how to log into gihub , with their
2 factor authentication . (this is dead complicated ) . I am not
even sure which TOTP apps is used nor if i used , i think
it involved the use of a mobile phone (??) (something i don't do
often .. ) . Or was it to log into Slack ? ( i remember slack
was also a PITA to log in ,alway asking for extra latest version
of browser ... ) .
This is probably why i did not keep up so much with the
Zoneminders news ...
Anyways , i will try to gain back my access to github , and look
into the v4l2 dependency issue ., and keep you posted .
best Regards
Ps: any new on the H265 front ? my own "custom" version of ZM
,with ZlMediaKit streaming server
for h264/h265 live view , has been working fine so far for me
(with Chrome browser on linux ) . That was a year ago , i believe
.
Bruno Grasland
On 7/2/25 15:50, Isaac Connor wrote:
connortechnology left a comment (ZoneMinder/zoneminder#3733)
I think my issue with this is... it makes v4l2 a
requirement... it should fall back to not using v4l2. So I'm not
opposed to this, but we need #else conditions
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message
ID: ***@***.***>
[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#3733 (comment)",
"url": "#3733 (comment)",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
|
|
Hey @sletteland did you ever get logged back into github? Not much on the h265 front, other than some work to support on-the-fly re-encode to h264 for those who can't support h265. WE have the go2rtc support, so if your browser supports it, it should work. I havn't tested it though. Just a ping here, I am aiming at Christmas for a 1.38 release and would love to get this in. I am thinking to just merge it as is... I think making v4l2 a required lib is not such a big deal anymore. I'll give it a test with my available v4l2 devices and see if it breaks anything. |
There was a problem hiding this comment.
Pull request overview
This PR aims to improve stability/compatibility for “primitive” local USB V4L2 cameras by routing LocalCamera device access through libv4l2 (v4l2_open/ioctl/mmap/etc.) instead of direct syscalls.
Changes:
- Switch LocalCamera device open/ioctl/mmap/munmap/close calls to libv4l2 wrappers.
- Add libv4l2 header include and adjust ioctl wrapper to use
v4l2_ioctl. - Change CMake default
ZM_EXTRA_LIBSto includev4l2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/zm_local_camera.cpp |
Uses libv4l2 wrappers for device access; adds libv4l2 include and modifies open/mmap/close paths. |
CMakeLists.txt |
Changes default extra libraries to link against libv4l2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -38,13 +42,15 @@ | |||
| static unsigned int BigEndian; | |||
| static bool primed; | |||
|
|
|||
| #if ZM_HAS_V4L2 | |||
| static int vidioctl(int fd, int request, void *arg) { | |||
| int result = -1; | |||
| do { | |||
| result = ioctl(fd, request, arg); | |||
| result = v4l2_ioctl( fd, request, arg ); | |||
| } while( result == -1 && errno == EINTR ); | |||
| return result; | |||
| } | |||
| #endif // ZM_HAS_V4L2 | |||
There was a problem hiding this comment.
#if ZM_HAS_V4L2 is currently based on finding linux/videodev2.h, but this patch unconditionally includes/uses libv4l2 (<libv4l2.h>, v4l2_open/ioctl/mmap/...) under the same macro. Systems with V4L2 headers but without libv4l2 installed will now fail to compile/link. Consider adding a separate CMake check for the V4L2::libv4l2 component and guarding the libv4l2 include/calls behind a dedicated macro, with a fallback to open/ioctl/mmap/close when libv4l2 is unavailable.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This allows very simple/primitive cameras to work out of the box . (like USB cameras using the gspca driver )
simple/primitive USB cameras ( for example using the gspsa driver ) do not work properly with ZoneMinder (zmc keeps crashing )
for example : 0c45:6005 Microdia Sweex Mini Webcam ,
I propose a fix for that (patch against zm 37.40 / master dev )
This uses libv4l2 (https://github.com/philips/libv4l) for local USB cameras .
This allows very simple/primitive cameras to work out of the box .
(like for example USB cameras using the gspca driver )
A pull Request has just been made (sletteland/zoneminder branch libv4l2 )