GNOME Bugzilla – Bug 607238
Still using max framerate during device enumeration.
Last modified: 2010-01-18 19:49:35 UTC
Created attachment 151614 [details] Limit framerate when getting webcam device data. Hi, some background information first: I have a PlayStation3 Eye, which is working fine with the latest gspca_ov534 driver from http://linuxtv.org/hg/~jfrancois/gspca/ However, with my particular usb host, I can't use the webcam maximum framerate 640x480@60fps, and Cheese! halts because of this. Running 'cheese --verbose' gives me: Cheese 2.28.1 Probing devices with HAL... Found device 1415:2000, getting capabilities... Detected v4l2 device: USB Camera-B4.04.27.1 Driver: ov534, version: 133120 Capabilities: 0x05000001 Probing supported video formats... (cheese:26533): GStreamer-WARNING **: pad source:src returned caps which are not a real subset of its template caps And I get the vidotestsrc image. I traced the problem to be in cheese-webcam.c::cheese_webcam_get_webcam_device_data: while Cheese! take good care of limiting the framerate to 30fps during normal operation, it is still assuming that the webcam can operate at the maximum one, in fact in cheese_webcam_get_webcam_device_data this pipeline is used: "v4l2src name=source device=%s ! fakesink" which I thinks lets gstreamer the freedom to use the max framerate; I checked with dmesg and in fact 60fps is set which makes Cheese! fail in my case. I can get Cheese! to work limiting the framerate also in the initial pipeline: "v4l2src name=source device=%s ! video/x-raw-rgb,framerate=[1/1, 30/1];video/x-raw-yuv,framerate=[1/1, 30/1] ! fakesink". See the attached patch. With this my webcam is detected fine: Cheese 2.28.1 Probing devices with HAL... Found device 1415:2000, getting capabilities... Detected v4l2 device: USB Camera-B4.04.27.1 Driver: ov534, version: 133120 Capabilities: 0x05000001 Probing supported video formats... (cheese:27190): GStreamer-WARNING **: pad source:src returned caps which are not a real subset of its template caps Device: USB Camera-B4.04.27.1 (/dev/video0) (cheese:27190): GStreamer-WARNING **: pad source:src returned caps which are not a real subset of its template caps video/x-raw-rgb 640 x 480 num_framerates 5 60/1 50/1 40/1 30/1 15/1 video/x-raw-rgb 320 x 240 num_framerates 6 100/1 75/1 60/1 50/1 40/1 30/1 video/x-raw-rgb 640 x 480 num_framerates 5 60/1 50/1 40/1 30/1 15/1 already added, skipping video/x-raw-rgb 320 x 240 num_framerates 6 100/1 75/1 60/1 50/1 40/1 30/1 already added, skipping video/x-raw-yuv 640 x 480 num_framerates 5 60/1 50/1 40/1 30/1 15/1 already added, skipping video/x-raw-yuv 320 x 240 num_framerates 6 100/1 75/1 60/1 50/1 40/1 30/1 already added, skipping video/x-raw-yuv 640 x 480 num_framerates 5 60/1 50/1 40/1 30/1 15/1 already added, skipping video/x-raw-yuv 320 x 240 num_framerates 6 100/1 75/1 60/1 50/1 40/1 30/1 already added, skipping video/x-raw-yuv 640 x 480 num_framerates 5 60/1 50/1 40/1 30/1 15/1 already added, skipping video/x-raw-yuv 320 x 240 num_framerates 6 100/1 75/1 60/1 50/1 40/1 30/1 already added, skipping v4l2src name=video_source device=/dev/video0 ! capsfilter name=capsfilter caps=video/x-raw-rgb,width=640,height=480,framerate=30/1;video/x-raw-yuv,width=640,height=480,framerate=30/1 ! identity I don't know if this solution is universally valid, I just wanted to report that this fixes the issue for me. Regards, Antonio Ospite http://ao2.it
Are you really sure that it fails in get_webcam_data? If that's really the case I'm afraid there is little chance to fix it. We cannot limit framerate in that call since we still don't know what the device actually supports. It's actually that call that retrieves supported formats and framerates. There is still some chance though that the issue is partially fixed with 2.29.5 since we removed the need to open the device for streaming in that call. Unfortunately I'm afraid that I could have removed the 30fps limit when I got rid of all the framerate code. I definitely need to find a way to restore it since I don't really want framerates higher than 30fps slowing down everything. Give me some time, I'll try to come up with a solution for 2.30.
Let me emphasize the pipeline I used to make it work: "v4l2src name=source device=%s ! video/x-raw-rgb,framerate=[1/1, 30/1];video/x-raw-yuv,framerate=[1/1, 30/1] ! fakesink". Look at the "framerate=[1/1, 30/1]" option, AFAIU this writing tells gstreamer to limit the framerate to those framerates supported by the webcam AND in the specified interval. So this is what you could use. I tried the cheese version from git, but It cannot even detect that the webcam is connected. Regards, Antonio
Created attachment 151637 [details] [review] Limit framerate when streaming. I am attaching a patch which fixes also 2.29.6 _for_me_ :) However this 'interval' writing I am using to limit framerates looks very generic, but I haven't found any official documentation about it, do you know where I can look and if it is valid for any gstreamer numerical property? Thanks, Antonio Ospite
(In reply to comment #2) > Look at the "framerate=[1/1, 30/1]" option Nice, this could really be a quick and easy solution, I'll do some test later today. Probably we could intersect supported caps with one containing a framerate range. > I tried the cheese version from git, but It cannot even detect that the webcam > is connected. Wait, do you mean that the webcam is not even detected? That's another bug then, but in the next comment you say it works just limiting the framerate so I'm guessing the detection works fine. Note that cheese -v for getting debug is going to be deprecated. The current way to get verbose output is GST_DEBUG=cheese*:3 cheese
Created attachment 151662 [details] [review] limit maximum framerate, temporary fix
Please test this patch, it's not the one that's going to be committed since I have to fix some error handling first. It should be enough to workaround your issue though. I'll work on this as soon as I have some spare time, maybe the next week.
The patch works Filippo, thanks. Regards, Antonio
The following fix has been pushed: 84f6d43 Limit maximum framerate to 30 frames per second
Created attachment 151699 [details] [review] Limit maximum framerate to 30 frames per second We don't really want those fancy webcams that claim to support huge framerates to slow down everything. 2.28.1 already limited it but I removed it while reworking caps handling. Implement GInitable interface in CheeseCameraDevice so we can abort construction and error out if something goes wrong while retrieving supported formats.