<commit_before>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)
<commit_msg>split pipeline into multiple bins, created in a pythonic way ;) - camsource generators\!<commit_after>import sys, inspect
from pprint import pprint
from gi.repository import GLib, Gst

class Videomix:
	decoder = []
	mixerpads = []

	def __init__(self):
		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
			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)

			# pass bin upstream
			yield camberabin



	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

{'fraction_non_alphanumeric': 0.12148268398268398, 'fraction_numerical': 0.017857142857142856, 'mean_word_length': 4.740683229813665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3672233', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1270, 'n_words': 243}