GNOME Bugzilla – Bug 740636
v4l2src: framerate is not always set on driver
Last modified: 2015-03-31 14:45:58 UTC
Created attachment 291377 [details] [review] a proposed fix when launching a simple chain and imposing a certain framerate, for example in this chain: gst-launch-1.0 -ef v4l2src device=/dev/video0 ! video/x-raw,format=GRAY8,framerate=60/1 ! mwebserver ! fakesink (mwebserver is a personal plugin), then the framerate is never set in the driver. I dug in the code and suspect that this bug was introduced in commit a7286563ee1fb0d3d2b3c24952288a8e493875da from the gst-plugins-good repository. I put a patch for a quickfix in attachment, but cannot guarantee this is complete. this code should be called but is never called: if (v4l2_ioctl (fd, VIDIOC_S_PARM, &streamparm) < 0) goto set_parm_failed;
the bug did not appear in gstreamer-1.0, but appears in gstreamer-1.4.
Having this filed against GStreamer project instead of gstreamermm-plugins-good will help ;-P
To be honest, I'm tempted to say we should probably not optimize out the S_FMT in the first place.
The context is that until recently, we had terrible hack that would get/set format while probing. This was actually leading toward format changing all the time. Clearly that had drastic performance issue, since getting/setting format thousands of times can take time. Though there is no measurable rational for avoiding a single format set, and this code has been the source of bugs for a long time. So I think we should just strip it up, and always set the format and the framerate.
Created attachment 292414 [details] [review] [PATCH] v4l2object: Always set format Right now we try to be clever by detecting if device format have changed or not, and skip setting format in this case. This is valid behaviour with V4L2, but it's also very error prone. The rational for not setting these all the time is for speed, though I can't measure any noticeable gain on any HW I own. Also, until recently, we where doing get/set on the format for each format we where probing, making it near to impossible that the format would match. This also fixes bug where we where skipping frame-rate setting if format didn't change. https://bugzilla.gnome.org/show_bug.cgi?id=740636 --- sys/v4l2/gstv4l2object.c | 70 +----------------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-)
Please let me know if that patch works as well for you.
Chris, any comment ?
You patch looks good; a more thorough change than what I proposed. I don't have an environment here that uses the gstreamer-1.4 framework yet. (I tested the upgrade to 1.4 for a while using the packman-rpms, but then we abandoned that upgrade for a while...)
Comment on attachment 292414 [details] [review] [PATCH] v4l2object: Always set format 1.5 commit 3dae65ede86e904145db27001e8ff60b9db03a60 Author: Nicolas Dufresne <nicolas.dufresne@collabora.com> Date: Tue Dec 9 15:09:56 2014 -0500 v4l2object: Always set format Right now we try to be clever by detecting if device format have changed or not, and skip setting format in this case. This is valid behaviour with V4L2, but it's also very error prone. The rational for not setting these all the time is for speed, though I can't measure any noticeable gain on any HW I own. Also, until recently, we where doing get/set on the format for each format we where probing, making it near to impossible that the format would match. This also fixes bug where we where skipping frame-rate setting if format didn't change. https://bugzilla.gnome.org/show_bug.cgi?id=740636 1.4 commit 67ac8
Nicolas, I upgraded and your fix works fine; just wanted to confirm :) tx.
Thanks for reporting !