Repository navigation
fix: enumerate V4L2 formats without frame sizes or frame intervals - #187
Merged
Merged
Conversation
Signed-off-by: Roman Ondráček <[email protected]>
Roman3349
force-pushed
the
fix/v4l2-frame-intervals
branch
from
November 6, 2026 15:36
9305478 to
e30c55c
Compare
kekyo
self-requested a review
November 9, 2026 02:24
Closed
Drivers such as stk1160 require more buffers than the requested two. Track the count returned by VIDIOC_REQBUFS so mapping and cleanup cover every allocated buffer.
Owner
|
Thanks, although I can't test it on actual analog devices, I think the code is good. I will merge it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some V4L2 drivers, such as the ones of analog video grabbers (EasyCAP and similar,
em28xx,stk1160,usbtv), don't implementVIDIOC_ENUM_FRAMEINTERVALS, and some don't implementVIDIOC_ENUM_FRAMESIZESeither. Their frame rate follows the video standard (PAL, NTSC) instead. FlashCap builds the video characteristics only from these enumerations, so such a device is listed with no characteristics and cannot be opened.Fixes #148
@marakhand, could you try this branch with your grabber? It would confirm the fix on a real device, since I could only test it with the
vividtest driver.Changes
V4L2Devicesfalls back when an enumeration returns nothing:VIDIOC_G_PARM(timeperframe). When that is not available either, the frame rate of the video standard fromVIDIOC_G_STD: 25 fps for the 625/50 standards (PAL, SECAM), 30000/1001 fps for the 525/60 ones (NTSC, PAL-M).VIDIOC_TRY_FMT, for each pixel format.The ioctl numbers are already in the generated per-architecture interop.
v4l2_streamparmandv4l2_std_idare passed as byte arrays with fixed offsets, because their layout is the same on all architectures, so the existingioctl<T>can pin them and no generated code changes.V4L2Deviceselects the format withVIDIOC_S_FMTand does not set the frame rate, so the fallback frame rate is only reported inVideoCharacteristics.Drivers which do enumerate sizes and intervals behave as before.
Testing
FlashCap.Core.Testspass.vividon Linux x86_64, .NET 10:vividdoes enumerate frame intervals for its TV and S-Video inputs on current kernels, so it doesn't reproduce the issue by itself. To test the fallback, I locally forced both enumerations to return nothing (not part of the PR):VIDIOC_G_PARMgave 25 fps for PAL and 29.97 fps (30000/1001) for NTSC, on the S-Video and the TV input.VIDIOC_G_PARMskipped as well,VIDIOC_G_STDgave the same frame rates.