<commit_before>import logging
from gi.repository import Gst

from lib.config import Config
from lib.tcpmulticonnection import TCPMultiConnection
from lib.clock import Clock


class AVRawOutput(TCPMultiConnection):

    def __init__(self, channel, port):
        self.log = logging.getLogger('AVRawOutput[{}]'.format(channel))
        super().__init__(port)

        self.channel = channel

        pipeline = """
            intervideosrc channel=video_{channel} !
            {vcaps} !
            queue !
            mux.

            interaudiosrc channel=audio_{channel} !
            {acaps} !
            queue !
            mux.

            matroskamux
                name=mux
                streamable=true
                writing-app=Voctomix-AVRawOutput !

            multifdsink
                blocksize=1048576
                buffers-max={buffers_max}
                sync-method=next-keyframe
                name=fd
        """.format(
            channel=self.channel,
            acaps=Config.get('mix', 'audiocaps'),
            vcaps=Config.get('mix', 'videocaps'),
            buffers_max=Config.getint('output-buffers', channel, fallback=500)
        )
        self.log.debug('Creating Output-Pipeline:\n%s', pipeline)<commit_msg>extend avrawoutput to support multiple streams<commit_after>import logging

from gi.repository import Gst

from lib.config import Config
from lib.tcpmulticonnection import TCPMultiConnection
from lib.clock import Clock


class AVRawOutput(TCPMultiConnection):
    def __init__(self, channel, port):
        self.log = logging.getLogger('AVRawOutput[{}]'.format(channel))
        super().__init__(port)

        self.channel = channel

        pipeline = """
            intervideosrc channel=video_{channel} !
            {vcaps} !
            queue !
            mux.
        """.format(
            channel=self.channel,
            vcaps=Config.get('mix', 'videocaps'),
        )

        for audiostream in range(0, Config.getint('mix', 'audiostreams')):
            pipeline += """
                interaudiosrc channel=audio_{channel}_stream{audiostream} !
                {acaps} !
                queue !
                mux.
            """.format(
                channel=self.channel,
                acaps=Config.get('mix', 'audiocaps'),
                audiostream=audiostream,
            )

        pipeline += """
            matroskamux
                name=mux
                streamable=true
                writing-app=Voctomix-AVRawOutput !

            multifdsink
                blocksize=1048576
                buffers-max={buffers_max}
                sync-method=next-keyframe
                name=fd
        """.format(
            buffers_max=Config.getint('output-buffers', channel, fallback=500)
        )
        self.log.debug('Creating Output-Pipeline:\n%s', pipeline)
{'fraction_non_alphanumeric': 0.10038474991255684, 'fraction_numerical': 0.007345225603357817, 'mean_word_length': 1.744721689059501, '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': '1335520', 'n_tokens_mistral': 810, 'n_tokens_neox': 753, 'n_words': 138}