diff options
author | MaZderMind <github@mazdermind.de> | 2014-07-30 00:04:44 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2014-07-30 00:04:44 +0200 |
commit | fc6609bdedef0ac245b16b041cb52731562d74c6 (patch) | |
tree | 1d9796f7eb096b9a3e5285f674d10006d02036ad | |
parent | 5c0570c8e66bc1e2e8167e8660305a28b7ba659b (diff) |
split pipeline into multiple bins, created in a pythonic way ;) - camsource generators\!
-rw-r--r-- | voctocore/videomix.py | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/voctocore/videomix.py b/voctocore/videomix.py index 4ed9d25..e67a7b1 100644 --- a/voctocore/videomix.py +++ b/voctocore/videomix.py @@ -7,11 +7,37 @@ class Videomix: mixerpads = [] def __init__(self): - self.pipeline = Gst.parse_launch(""" + self.pipeline = Gst.Pipeline() + + # create audio and video mixer + mixerbin = self.createMixer() + self.pipeline.add(mixerbin) + + # create camera sources + for camberabin in self.createDummyCamSources(): + # link camerasource to the mixers + self.pipeline.add(camberabin) + camberabin.get_by_name('video_src').link(self.pipeline.get_by_name('livevideo')) + camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio')) + + # demonstrate some control + 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) + + def createMixer(self): + return Gst.parse_bin_from_description(""" videomixer name=livevideo ! autovideosink input-selector name=liveaudio ! autoaudiosink - """) - + """, False) + + + def createDummyCamSources(self): uris = ('file:///home/peter/122.mp4', 'file:///home/peter/10025.mp4',) for idx, uri in enumerate(uris): # create a bin for camera input @@ -24,17 +50,22 @@ class Videomix: # configure camera input camberabin.get_by_name('input').set_property('uri', uri) - # add to pipeline and link to mixers - self.pipeline.add(camberabin) - camberabin.get_by_name('video_src').link(self.pipeline.get_by_name('livevideo')) - camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio')) + # pass bin upstream + yield camberabin - # demonstrate some control - 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) + def createCamSources(self): + for cam in range(2): + # create a bin for camera input + camberabin = Gst.parse_bin_from_description(""" + decklinksrc name=input input=sdi input-mode=1080p25 + input. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1920,height=1080,framerate=25/1 ! identity name=video_src + input. ! audioconvert name=audio_src + """, False) + + # configure camera input + camberabin.get_by_name('input').set_property('subdevice', cam) + + # pass bin upstream + yield camberabin |