diff options
author | Daniel Drake <dsd@laptop.org> | 2010-05-27 20:27:12 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2010-05-27 20:28:36 (GMT) |
commit | 7cd3274e0e12fcda8d12e17316280b057e014e2c (patch) | |
tree | 1b1b9e9af56ff090392b664dcd4add3bf230129c | |
parent | d43006e176d2f3cb23b3d65afcc8b9444f314842 (diff) |
Only limit framerate on v4l2 element when supported
XO-1 capture was broken because the camera driver doesn't support
framerate changes right now.
Add some code to check if this capability is available before using it.
-rw-r--r-- | glive.py | 31 | ||||
-rw-r--r-- | glivex.py | 11 |
2 files changed, 33 insertions, 9 deletions
@@ -51,9 +51,24 @@ THUMB_STUB = gtk.gdk.pixbuf_new_from_file( def _does_camera_present(): v4l2src = gst.element_factory_make('v4l2src') - return v4l2src.props.device_name is not None - -camera_presents = _does_camera_present() + if v4l2src.props.device_name is None: + return False, False + + # Figure out if we can place a framerate limit on the v4l2 element, which + # in theory will make it all the way down to the hardware. + # ideally, we should be able to do this by checking caps. However, I can't + # find a way to do this (at this time, XO-1 cafe camera driver doesn't + # support framerate changes, but gstreamer caps suggest otherwise) + pipeline = gst.Pipeline() + caps = gst.Caps("video/x-raw-yuv,framerate=10/1") + fsink = gst.element_factory_make("fakesink") + pipeline.add(v4l2src, fsink) + v4l2src.link(fsink, caps) + can_limit_framerate = pipeline.set_state(gst.STATE_PAUSED) != gst.STATE_CHANGE_FAILURE + pipeline.set_state(gst.STATE_NULL) + return True, can_limit_framerate + +camera_presents, can_limit_framerate = _does_camera_present() class Glive: def __init__(self, pca): @@ -196,9 +211,13 @@ class Glive: except: pass - # important to place the framerate limit directly on the v4l2src - # so that it gets communicated all the way down to the camera level - srccaps = gst.Caps('video/x-raw-yuv,framerate='+str(self.VIDEO_FRAMERATE_SMALL)+'/1') + # if possible, it is important to place the framerate limit directly + # on the v4l2src so that it gets communicated all the way down to the + # camera level + if can_limit_framerate: + srccaps = gst.Caps('video/x-raw-yuv,framerate='+str(self.VIDEO_FRAMERATE_SMALL)+'/1') + else: + srccaps = gst.Caps('video/x-raw-yuv') # we attempt to limit the framerate on the v4l2src directly, but we # can't trust this: perhaps we are falling behind in our capture, @@ -46,6 +46,7 @@ from constants import Constants import record import utils import ui +import glive class GliveX: def __init__(self, pca): @@ -72,9 +73,13 @@ class GliveX: except: pass - # important to place the framerate limit directly on the v4l2src - # so that it gets communicated all the way down to the camera level - srccaps = gst.Caps('video/x-raw-yuv,framerate='+str(self.VIDEO_FRAMERATE_SMALL)+'/1') + # if possible, important to place the framerate limit directly on the + # v4l2src so that it gets communicated all the way down to the camera + # level + if glive.can_limit_framerate: + srccaps = gst.Caps('video/x-raw-yuv,framerate='+str(self.VIDEO_FRAMERATE_SMALL)+'/1') + else: + srccaps = gst.Caps('video/x-raw-yuv') # the XO-1.5 camera framerate limit increases image quality but # still delivers way too many frames. add a gstreamer-level filter |