import sys, inspect
from pprint import pprint
from gi.repository import GLib, Gst

class Videomix:
	decoder = []
	mixerpads = []

	def __init__(self):
		self.pipeline = Gst.parse_launch("""
			videomixer name=livevideo ! autovideosink
			input-selector name=liveaudio ! autoaudiosink
		""")
		
		uris = ('file:///home/peter/122.mp4', 'file:///home/peter/10025.mp4',)
		for idx, uri in enumerate(uris):
			# create a bin for camera input
			camberabin = Gst.parse_bin_from_description("""
				uridecodebin name=input
				input. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1024,height=576,framerate=25/1 ! identity name=video_src
				input. ! audioconvert name=audio_src
			""", False)

			# 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'))

		# 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)

@@ -170,20 +170,828 @@
 Gst.
-parse_launch
+Pipeline()%0A%0A%09%09# create audio and video mixer%0A%09%09mixerbin = self.createMixer()%0A%09%09self.pipeline.add(mixerbin)%0A%0A%09%09# create camera sources%0A%09%09for camberabin in self.createDummyCamSources():%0A%09%09%09# link camerasource to the mixers%0A%09%09%09self.pipeline.add(camberabin)%0A%09%09%09camberabin.get_by_name('video_src').link(self.pipeline.get_by_name('livevideo'))%0A%09%09%09camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio'))%0A%0A%09%09# demonstrate some control%0A%09%09liveaudio = self.pipeline.get_by_name('liveaudio')%0A%09%09liveaudio.set_property('active-pad', liveaudio.get_static_pad('sink_0'))%0A%0A%09%09livevideo = self.pipeline.get_by_name('livevideo')%0A%09%09pad = livevideo.get_static_pad('sink_1')%0A%09%09pad.set_property('alpha', 0.5)%0A%0A%09%09self.pipeline.set_state(Gst.State.PLAYING)%0A%0A%09def createMixer(self):%0A%09%09return Gst.parse_bin_from_description
 (%22%22%22
@@ -1090,20 +1090,60 @@
 nk%0A%09%09%22%22%22
-)%0A%09%09
+, False)%0A%0A%0A%09def createDummyCamSources(self):
 %0A%09%09uris 
@@ -1640,504 +1640,491 @@
 %09%09# 
-add to pipeline and link to mixers%0A%09%09%09self.pipeline.add(camberabin)%0A%09%09%09camberabin.get_by_name('video_src').link(self.pipeline.get_by_name('livevideo'))%0A%09%09%09camberabin.get_by_name('audio_src').link(self.pipeline.get_by_name('liveaudio'))%0A%0A%09%09# demonstrate some control%0A%09%09liveaudio = self.pipeline.get_by_name('liveaudio')%0A%09%09liveaudio.set_property('active-pad', liveaudio.get_static_pad('sink_0'))%0A%0A%09%09livevideo = self.pipeline.get_by_name('livevideo')%0A%09%09pad = livevideo.get_static_pad
+pass bin upstream%0A%09%09%09yield camberabin%0A%0A%0A%0A%09def createCamSources(self):%0A%09%09for cam in range(2):%0A%09%09%09# create a bin for camera input%0A%09%09%09camberabin = Gst.parse_bin_from_description(%22%22%22%0A%09%09%09%09decklinksrc name=input input=sdi input-mode=1080p25%0A%09%09%09%09input. ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1920,height=1080,framerate=25/1 ! identity name=video_src%0A%09%09%09%09input. ! audioconvert name=audio_src%0A%09%09%09%22%22%22, False)%0A%0A%09%09%09# configure camera input%0A%09%09%09camberabin.get_by_name
 ('
-s
 in
-k_1')%0A%09%09pad
+put')
 .set
@@ -2138,63 +2138,65 @@
 ty('
-alpha', 0.5)%0A%0A%09%09self.pipeline.set_state(Gst.State.PLAYING)
+subdevice', cam)%0A%0A%09%09%09# pass bin upstream%0A%09%09%09yield camberabin
 %0A

split pipeline into multiple bins, created in a pythonic way ;) - camsource generators\!