1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 from twisted.internet import reactor
19 import gobject
20 import gst
21
22 from flumotion.common.i18n import N_, gettexter
23 from flumotion.component import feedcomponent
24
25
26 from flumotion.common import messages
27
28 __version__ = "$Rev$"
29 T_ = gettexter()
30
31
33 """
34 I am a GStreamer bin that can change the framerate of a video stream.
35 """
36 logCategory = "videosrate"
37 CAPS_TEMPLATE = "video/x-raw-yuv%(fr)s;"\
38 "video/x-raw-rgb%(fr)s"
39
40 __gproperties__ = {
41 'framerate': (gobject.TYPE_OBJECT, 'framerate',
42 'Video framerate', gobject.PARAM_READWRITE)}
43
44 - def __init__(self, framerate=gst.Fraction(25, 1)):
45 gst.Bin.__init__(self)
46 self._framerate = framerate
47
48 self._videorate = gst.element_factory_make("videorate")
49 self._capsfilter = gst.element_factory_make("capsfilter")
50 self.add(self._videorate, self._capsfilter)
51
52 self._videorate.link(self._capsfilter)
53
54
55 self._sinkPad = gst.GhostPad('sink', self._videorate.get_pad('sink'))
56 self._srcPad = gst.GhostPad('src', self._capsfilter.get_pad('src'))
57 self.add_pad(self._sinkPad)
58 self.add_pad(self._srcPad)
59
60 self._setFramerate(framerate)
61
66
68 if property.name == 'framerate':
69 self._setFramerate(value)
70 else:
71 raise AttributeError('unknown property %s' % property.name)
72
74 if property.name == 'framerate':
75 return self._framerate
76 else:
77 raise AttributeError('unknown property %s' % property.name)
78
80 if self._framerate is None:
81 return ""
82 return ",framerate=(fraction)%d/%d" % (self._framerate.num,
83 self._framerate.denom)
84
85
86 -class Videorate(feedcomponent.PostProcEffect):
87 """
88 I am an effect that can be added to any component that has a videorate
89 component and a way of changing the output framerate.
90 """
91 logCategory = "videorate-effect"
92
93 - def __init__(self, name, sourcePad, pipeline, framerate):
94 """
95 @param element: the video source element on which the post
96 processing effect will be added
97 @param sourcePad: source pad used for linking the effect
98 @param pipeline: the pipeline of the element
99 @param framerate: output framerate
100 """
101 feedcomponent.PostProcEffect.__init__(self, name, sourcePad,
102 VideorateBin(framerate), pipeline)
103
105 self.effectBin.set_property("framerate", framerate)
106 return framerate
107
109 return self.effectBin.get_property('framerate')
110