diff options
author | MaZderMind <github@mazdermind.de> | 2014-07-29 22:50:17 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2014-07-29 22:50:17 +0200 |
commit | c752709208522a5a04416e0d033aa32f8c0dc8c0 (patch) | |
tree | 87d0bda4a41e03e28bee71d0de34bbf96d12f1f9 /voctocore | |
parent | eb7baef5bac14c001ef8b448dda05b464d68f99a (diff) |
setting stuff up with a launch-string is far more easy
Diffstat (limited to 'voctocore')
-rw-r--r-- | voctocore/videomix.py | 78 |
1 files changed, 20 insertions, 58 deletions
diff --git a/voctocore/videomix.py b/voctocore/videomix.py index 895a25f..1426cb4 100644 --- a/voctocore/videomix.py +++ b/voctocore/videomix.py @@ -7,63 +7,25 @@ class Videomix: mixerpads = [] def __init__(self): - self.pipeline = Gst.Pipeline() - - self.videomixer = Gst.ElementFactory.make('videomixer', 'videomixer') - self.pipeline.add(self.videomixer) - - for uri in ("http://video.blendertestbuilds.de/download.blender.org/ED/ED_1280.avi", "http://download.blender.org/durian/trailer/sintel_trailer-720p.mp4",): - decoder = Gst.ElementFactory.make('uridecodebin', 'uridecoder('+uri+')') - decoder.set_property("uri", uri) - decoder.connect("pad-added", self.OnDynamicPad) - self.pipeline.add(decoder) - self.decoder.append(decoder) - - self.monitorvideosink = Gst.ElementFactory.make('autovideosink', 'monitorvideosink') - self.pipeline.add(self.monitorvideosink) - self.videomixer.link(self.monitorvideosink) - - self.monitoraudiosink = Gst.ElementFactory.make('autoaudiosink', 'monitoraudiosink') - self.pipeline.add(self.monitoraudiosink) + self.pipeline = Gst.parse_launch(""" + videomixer name=livevideo ! autovideosink + input-selector name=liveaudio ! autoaudiosink + + uridecodebin name=cam0 uri=file:///home/peter/122.mp4 + uridecodebin name=cam1 uri=file:///home/peter/10025.mp4 + + cam0. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1024,height=576,framerate=25/1 ! livevideo. + cam1. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1024,height=576,framerate=25/1 ! livevideo. + + cam0. ! audioconvert ! liveaudio. + cam1. ! audioconvert ! liveaudio. + """) + + liveaudio = self.pipeline.get_by_name('liveaudio') + liveaudio.set_property('active-pad', liveaudio.get_static_pad('sink_0')) + + livevideo = self.pipeline.get_by_name('livevideo') + pad = livevideo.get_static_pad('sink_1') + pad.set_property('alpha', 0.5) self.pipeline.set_state(Gst.State.PLAYING) - - GLib.io_add_watch(sys.stdin, GLib.IO_IN, self.Input) - - def Input(self, fd, condition): - if condition == GLib.IO_IN: - char = fd.readline() - try: - i = int(char.rstrip()) - print("settinh pad {0} to alpha=1".format(i)) - self.mixerpads[i].set_property('alpha', 1) - for idx, pad in enumerate(self.mixerpads): - if idx != i: - print("settinh pad {0} to alpha=0".format(idx)) - pad.set_property('alpha', 0) - except: - pass - - return True - else: - return False - - def OnDynamicPad(self, uridecodebin, src_pad): - caps = src_pad.query_caps(None).to_string() - srcname = uridecodebin.get_name() - print("{0}-source of {1} online".format(caps.split(',')[0], srcname)) - - if caps.startswith('audio/'): - sinkpad = self.monitoraudiosink.get_static_pad("sink") - - # link the first audio-stream and be done - if not sinkpad.is_linked(): - src_pad.link(sinkpad) - - else: - sinkpad = Gst.Element.get_request_pad(self.videomixer, "sink_%u") - src_pad.link(sinkpad) - self.mixerpads.append(sinkpad) - print('add', sinkpad) - sinkpad.set_property('alpha', 0.7) - |