diff options
author | MaZderMind <github@mazdermind.de> | 2014-07-30 00:34:14 +0200 |
---|---|---|
committer | MaZderMind <github@mazdermind.de> | 2014-07-30 00:34:14 +0200 |
commit | 1c425ec2eeb78085939c0c93f2a69c8a73e709b9 (patch) | |
tree | 18de5ebc2f71e91c6d89ef3932f3f9b8b4b337bf /voctocore/videomix.py | |
parent | fc6609bdedef0ac245b16b041cb52731562d74c6 (diff) |
add a distributor piping into two different mixes, start placing videos in quadmix
Diffstat (limited to 'voctocore/videomix.py')
-rw-r--r-- | voctocore/videomix.py | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/voctocore/videomix.py b/voctocore/videomix.py index e67a7b1..8cc3cb9 100644 --- a/voctocore/videomix.py +++ b/voctocore/videomix.py @@ -1,4 +1,4 @@ -import sys, inspect +import sys, inspect, math from pprint import pprint from gi.repository import GLib, Gst @@ -11,15 +11,27 @@ class Videomix: # create audio and video mixer mixerbin = self.createMixer() - self.pipeline.add(mixerbin) + + # collection of video-sources to connect to the quadmix + quadmixSources = [] # 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')) + # link camerasource to audiomixer camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio')) + # inject a ×2 distributor and link one end to the live-mixer + distributor = self.createDistributor(camberabin.get_by_name('video_src')) + distributor.get_by_name('a').link(self.pipeline.get_by_name('livevideo')) + + # collect the other end to add it later to the quadmix + quadmixSources.append(distributor.get_by_name('b')) + + # would generate pause & slides with another generator which only + # yields if the respective fil are there and which only have a video-pad + + self.addVideosToQuadmix(quadmixSources, self.pipeline.get_by_name('quadmix')) + # demonstrate some control liveaudio = self.pipeline.get_by_name('liveaudio') liveaudio.set_property('active-pad', liveaudio.get_static_pad('sink_0')) @@ -31,11 +43,33 @@ class Videomix: self.pipeline.set_state(Gst.State.PLAYING) def createMixer(self): - return Gst.parse_bin_from_description(""" + mixerbin = Gst.parse_bin_from_description(""" videomixer name=livevideo ! autovideosink input-selector name=liveaudio ! autoaudiosink + + videomixer name=quadmix ! autovideosink + """, False) + self.pipeline.add(mixerbin) + return mixerbin + + def addVideosToQuadmix(self, videosources, quadmix): + count = len(videosources) + rows = math.ceil(math.sqrt(count)) + cols = math.ceil(count / rows) + for videosource in videosources: + # define size somewhere, scale and place here + videosource.link(quadmix) + + def createDistributor(self, videosource): + distributor = Gst.parse_bin_from_description(""" + tee name=t + t. ! queue name=a + t. ! queue name=b """, False) + self.pipeline.add(distributor) + videosource.link(distributor.get_by_name('t')) + return distributor def createDummyCamSources(self): uris = ('file:///home/peter/122.mp4', 'file:///home/peter/10025.mp4',) @@ -51,6 +85,7 @@ class Videomix: camberabin.get_by_name('input').set_property('uri', uri) # pass bin upstream + self.pipeline.add(camberabin) yield camberabin @@ -68,4 +103,5 @@ class Videomix: camberabin.get_by_name('input').set_property('subdevice', cam) # pass bin upstream + self.pipeline.add(camberabin) yield camberabin |