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 Fluendo, S.L. (www.fluendo.com). 
 6  # All rights reserved. 
 7   
 8  # This file may be distributed and/or modified under the terms of 
 9  # the GNU General Public License version 2 as published by 
10  # the Free Software Foundation. 
11  # This file is distributed without any warranty; without even the implied 
12  # warranty of merchantability or fitness for a particular purpose. 
13  # See "LICENSE.GPL" in the source distribution for more information. 
14   
15  # Licensees having purchased or holding a valid Flumotion Advanced 
16  # Streaming Server license may use this file in accordance with the 
17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
18  # See "LICENSE.Flumotion" in the source distribution for more information. 
19   
20  # Headers in this file shall remain intact. 
21   
22  from flumotion.component import feedcomponent 
23  from flumotion.common import messages 
24   
25  from flumotion.common.messages import N_ 
26  T_ = messages.gettexter('flumotion') 
27   
28 -class Theora(feedcomponent.ParseLaunchComponent):
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 d = encoder.checkTheora() 36 37 d.addCallback(self._checkCallback) 38 39 return d
40
41 - def _checkCallback(self, result):
42 for m in result.messages: 43 self.addMessage(m)
44
45 - def get_pipeline_string(self, properties):
46 return "ffmpegcolorspace ! theoraenc name=encoder"
47
48 - def configure_pipeline(self, pipeline, properties):
49 element = pipeline.get_by_name('encoder') 50 51 props = ('bitrate', 52 'quality', 53 'keyframe-threshold', 54 'keyframe-mindistance', 55 ('quick-compress', 'quick'), 56 ('keyframe-maxdistance', 'keyframe-freq'), 57 ('keyframe-maxdistance', 'keyframe-force'), 58 'noise-sensitivity') 59 60 # F0.6: remove this code 61 # before 0.3.2, bitrate was interpreted as kbps, inconsistent 62 # with other flumotion components 63 # safe to assume that nobody will want less than 10 kbit/sec 64 # also, MikeS *requires* a kbit/sec to be seen as 1000 bit/sec 65 if 'bitrate' in properties: 66 if properties['bitrate'] < 10000: 67 self.addMessage( 68 messages.Warning(T_(N_( 69 "Your configuration uses 'bitrate' expressed in " 70 "kbit/sec. Please convert it to a value in bit/sec by " 71 "multiplying the value by 1000.")), id='bitrate')) 72 properties['bitrate'] *= 1000 73 74 for p in props: 75 pproperty = isinstance(p, tuple) and p[0] or p 76 eproperty = isinstance(p, tuple) and p[1] or p 77 78 if pproperty in properties: 79 self.debug('Setting GStreamer property %s to %r' % ( 80 eproperty, properties[pproperty])) 81 # FIXME: GStreamer 0.10 has bitrate in kbps, inconsistent 82 # with all other elements, so fix it up 83 if pproperty == 'bitrate': 84 element.set_property(eproperty, 85 int(properties[pproperty]/1000)) 86 else: 87 element.set_property(eproperty, properties[pproperty])
88