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

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

 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 
19  from flumotion.common.i18n import N_, gettexter 
20  from flumotion.component import feedcomponent 
21   
22   
23  __version__ = "$Rev$" 
24  T_ = gettexter() 
25   
26   
27 -class VP8(feedcomponent.EncoderComponent):
28 checkTimestamp = True 29 checkOffset = True 30
31 - def check_properties(self, props, addMessage):
32 33 def check_limit(prop_name, lower_limit, upper_limit): 34 val = props.get(prop_name, None) 35 if val is None: 36 return 37 if val < lower_limit or val > upper_limit: 38 msg = messages.Error(T_(N_( 39 "The configuration property '%s' can only take " 40 "values from %d to %d"), 41 prop_name, lower_limit, upper_limit), mid='config') 42 addMessage(msg) 43 raise errors.ConfigError(msg)
44 45 check_limit('speed', 0, 7) 46 check_limit('threads', 1, 64)
47
48 - def get_pipeline_string(self, properties):
49 return "ffmpegcolorspace ! vp8enc name=encoder"
50
51 - def configure_pipeline(self, pipeline, properties):
52 element = pipeline.get_by_name('encoder') 53 54 props = (('bitrate', 'bitrate', 400), 55 ('quality', 'quality', None), 56 ('speed', 'speed', 2), 57 ('threads', 'threads', 4), 58 ('keyframe-maxdistance', 'max-keyframe-distance', 50)) 59 60 for pproperty, eproperty, default in props: 61 if eproperty is None: 62 eproperty = properties 63 64 if not pproperty in properties and default is None: 65 continue 66 67 value = properties.get(pproperty, default) 68 self.debug('Setting GStreamer property %s to %r' % ( 69 eproperty, value)) 70 71 element.set_property(eproperty, value)
72
73 - def modify_property_Bitrate(self, value):
74 if not self.checkPropertyType('bitrate', value, int): 75 return False 76 self.modify_element_property('encoder', 'bitrate', value) 77 return True
78