Package flumotion :: Package component :: Package converters :: Package video :: Module video
[hide private]

Source Code for Module flumotion.component.converters.video.video

 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.common import errors, messages 
23  from flumotion.common.i18n import N_, gettexter 
24  from flumotion.component import feedcomponent 
25  from flumotion.component.effects.videorate import videorate 
26  from flumotion.component.effects.videoscale import videoscale 
27  from flumotion.component.effects.deinterlace import deinterlace 
28   
29  __all__ = ['Converter'] 
30  __version__ = "$Rev$" 
31  T_ = gettexter() 
32   
33   
34 -class Converter(feedcomponent.ParseLaunchComponent):
35 logCategory = 'videoconvert' 36
37 - def check_properties(self, props, addMessage):
38 props = self.config['properties'] 39 deintMode = props.get('deinterlace-mode', 'auto') 40 deintMethod = props.get('deinterlace-method', 'ffmpeg') 41 is_square = props.get('is-square', False) 42 width = props.get('width', None) 43 height = props.get('height', None) 44 45 if deintMode not in deinterlace.DEINTERLACE_MODE: 46 msg = "'%s' is not a valid deinterlace mode." % deintMode 47 raise errors.ConfigError(msg) 48 if deintMethod not in deinterlace.DEINTERLACE_METHOD: 49 msg = "'%s' is not a valid deinterlace method." % deintMethod 50 raise errors.ConfigError(msg)
51
52 - def get_pipeline_string(self, properties):
53 return 'identity name=identity'
54
55 - def configure_pipeline(self, pipeline, properties):
56 self.deintMode = properties.get('deinterlace-mode', "auto") 57 self.deintMethod = properties.get('deinterlace-method', "ffmpeg") 58 self.framerate = properties.get('framerate', None) 59 self.width = properties.get('width', None) 60 self.height = properties.get('height', None) 61 self.is_square = properties.get('is-square', False) 62 63 identity = pipeline.get_by_name("identity") 64 # Add videorate effect. The videorate is usually decreased, so it's 65 # usefull to have this effect always first, because it reduces the 66 # number of frames to process. 67 vr = videorate.Videorate('videorate', 68 identity.get_pad("src"), pipeline, self.framerate) 69 self.addEffect(vr) 70 vr.plug() 71 # Add deinterlace effect. Deinterlacing must always be done 72 # before scaling. 73 deinterlacer = deinterlace.Deinterlace('deinterlace', 74 vr.effectBin.get_pad("src"), 75 pipeline, self.deintMode, self.deintMethod) 76 self.addEffect(deinterlacer) 77 deinterlacer.plug() 78 # Add videoscale effect 79 videoscaler = videoscale.Videoscale('videoscale', self, 80 deinterlacer.effectBin.get_pad("src"), pipeline, 81 self.width, self.height, self.is_square) 82 self.addEffect(videoscaler) 83 videoscaler.plug()
84