Package flumotion :: Package component :: Package encoders :: Package theora :: Module theora
[hide private]

Source Code for Module flumotion.component.encoders.theora.theora

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
17   
18  from flumotion.common import messages, errors, gstreamer 
19  from flumotion.common.i18n import N_, gettexter 
20  from flumotion.component import feedcomponent 
21  from flumotion.worker.checks import check 
22   
23   
24  __version__ = "$Rev$" 
25  T_ = gettexter() 
26   
27   
28 -class Theora(feedcomponent.EncoderComponent):
29 checkTimestamp = True 30 checkOffset = True 31
32 - def do_check(self):
33 self.debug('running Theora check') 34 from flumotion.worker.checks import encoder 35 return check.do_check(self, encoder.checkTheora)
36
37 - def check_properties(self, props, addMessage):
38 props = self.config['properties'] 39 speed = props.get('speed', 3) 40 41 if speed > 3: 42 msg = messages.Error(T_(N_( 43 "The configuration property 'speed' can only take " 44 "values from 0 to 3")), mid='speed') 45 addMessage(msg) 46 raise errors.ConfigError(msg)
47
48 - def get_pipeline_string(self, properties):
49 return "ffmpegcolorspace ! theoraenc name=encoder"
50
51 - def configure_pipeline(self, pipeline, properties):
52 element = pipeline.get_by_name('encoder') 53 54 for p in ['sharpness', 'quick-compress', 'noise-sensitivity']: 55 if properties.get(p, None) is not None: 56 self.warnDeprecatedProperties([p]) 57 58 props = ('bitrate', 59 'quality', 60 ('speed', 'speed-level'), 61 ('keyframe-mindistance', 'keyframe-freq'), 62 ('keyframe-maxdistance', 'keyframe-force')) 63 64 for p in props: 65 if isinstance(p, tuple): 66 pproperty, eproperty = p 67 else: 68 pproperty = eproperty = p 69 70 if not pproperty in properties: 71 continue 72 73 value = properties[pproperty] 74 self.debug('Setting GStreamer property %s to %r' % ( 75 eproperty, value)) 76 77 # FIXME: GStreamer 0.10 has bitrate in kbps, inconsistent 78 # with all other elements, so fix it up 79 if pproperty == 'bitrate': 80 value = int(value/1000) 81 # Check for the speed-level property, introduced in 82 # gst-plugins-base-0.10.24 83 if eproperty == 'speed-level': 84 if not gstreamer.element_has_property(element, 'speed-level'): 85 self.warning("Trying to set the 'speed-level' property " 86 "in a old version of gstreamer's theora " 87 "encoder element") 88 self.warning("We will fallback to the 'quick' property") 89 eproperty = 'quick' 90 value = value > 0 and True or False 91 element.set_property(eproperty, value)
92
93 - def modify_property_Bitrate(self, value):
94 if not self.checkPropertyType('bitrate', value, int): 95 return False 96 self.modify_element_property('encoder', 'bitrate', value/1000) 97 return True
98