]> git.parisson.com Git - telecaster-server.git/commitdiff
add audio engine and tools in py script
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 8 Jun 2025 23:04:45 +0000 (01:04 +0200)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 8 Jun 2025 23:04:45 +0000 (01:04 +0200)
bin/streaming/telecaster.py
bin/streaming/telecaster.sh

index ae4ed3a9e106ca45d0e20b6634c8a622b237e86b..ba96b0f2286cf742ce3a36ea0d757700bea73bd2 100755 (executable)
@@ -13,18 +13,18 @@ from copy import deepcopy
 VIDEO_PIPELINE_BASE="""{video_source} {video_options} \
     ! {format}, width={width}, height={height}, framerate={framerate}/1 \
     ! {decoder} \
-    ! videoflip method={flip} \
-    ! videoconvert \
-    ! vp8enc threads=4 deadline=2 target-bitrate={vp8_bitrate} \
+    ! queue ! videoflip method={flip} \
+    ! queue ! videoconvert \
+    ! queue ! vp8enc threads=4 deadline=2 target-bitrate={vp8_bitrate} \
     ! muxout. \
     {audio_source} {audio_options} client-name="webm_streaming_{id}_audio" ! audio/x-raw, format=F32LE, channels={channels} \
-    ! audiocheblimit mode=high-pass cutoff=120 poles=4 \
-    ! volume volume={gain_pre} \
-    ! audiodynamic characteristics=soft-knee mode=compressor threshold=0.125 ratio=0.125 \
-    ! volume volume={gain_post} \
-    ! audiodynamic characteristics=hard-knee mode=compressor threshold=0.95 ratio=0.001 \
-    ! audioconvert \
-    ! opusenc bitrate={opus_bitrate} \
+    ! queue ! audiocheblimit mode=high-pass cutoff=120 poles=4 \
+    ! queue ! volume volume={gain_pre} \
+    ! queue ! audiodynamic characteristics=soft-knee mode=compressor threshold=0.125 ratio=0.125 \
+    ! queue ! volume volume={gain_post} \
+    ! queue ! audiodynamic characteristics=hard-knee mode=compressor threshold=0.95 ratio=0.001 \
+    ! queue ! audioconvert \
+    ! queue ! opusenc bitrate={opus_bitrate} \
     ! muxout. \
     webmmux streamable=true name=muxout \
     ! queue ! shout2send ip={ip} port={port} password={password} mount=telecaster_live_{id}.webm > /dev/null
@@ -42,17 +42,26 @@ AUDIO_PIPELINE_BASE="""{audio_source} {audio_options} \
     ! queue ! shout2send ip={ip} port={port} password={password} mount=telecaster_live.mp3 > /dev/null
 """
 
-BOOT_TIME_DELAY = 0
+BOOT_TIME_DELAY = 1
 
 DEFAULT_CONFIG_FILE = "/etc/telecaster/telecaster.yml"
 
+JACK_CONFIG = {"engine": "jackd",
+               "options": "-R -P50 -dalsa -r48000 -p1024 -n3 -Chw:3 -Phw:3",
+               "tools": ["catia", "konsole"]}
+
+PIPEWIRE_CONFIG = {"engine": "pipewire",
+               "options": "",
+               "tools": ["qpwgraph", "konsole"]}
+
+
 
 class TeleCasterGStream(Thread):
 
     def __init__(self, pipeline):
         Thread.__init__(self)
         self.pipeline = pipeline
-        print(self.pipeline)
+        print(self.pipeline)
 
     def run(self):
         os.system('gst-launch-1.0 ' + self.pipeline + ' & ')
@@ -68,6 +77,25 @@ class TeleCasterDeeFuzzer(Thread):
         os.system('deefuzzer ' + self.conf_file + ' & ')
 
 
+class TeleCasterThreadedCommand(Thread):
+
+    def __init__(self, command):
+        Thread.__init__(self)
+        self.command = command
+
+    def run(self):
+        os.system(self.command + ' & ')
+
+
+class TeleCasterCommand:
+
+    def __init__(self, command):
+        self.command = command
+
+    def start(self):
+        os.system(self.command + ' & ')
+
+
 class TeleCaster(Thread):
 
     def __init__(self, conf_file_path):
@@ -78,6 +106,11 @@ class TeleCaster(Thread):
         self.deefuzzer_video_conf_file = "/tmp/telecaster_deefuzzer_webm_monitor.yml"
         self.deefuzzer_audio_conf_file = "/tmp/telecaster_deefuzzer_mp3_monitor.yml"
         # print(self.conf)
+        audio_source = self.conf["audio"]["gstreamer"]["audio_source"]
+        if "pipewire" in audio_source:
+            audio_config = PIPEWIRE_CONFIG
+        elif "jack" in audio_source:
+            audio_config = JACK_CONFIG
 
     def write_conf(self, conf_dict, path):
         filename, ext = os.path.splitext(path)
@@ -94,6 +127,21 @@ class TeleCaster(Thread):
             # print(args)
             subprocess.call(command, shell=True)
 
+    def audio_engine_start(self):
+        command = self.audio_config["engine"] + " " + self.audio_config["options"]
+        thread = TeleCasterCommand(command)
+        Thread.start()
+
+    def audio_engine_start(self):
+        command = self.audio_config["engine"] + " " + self.audio_config["options"]
+        thread = TeleCasterCommand(command)
+        Thread.start()
+
+    def audio_tools_start(self):
+        for tool in self.audio_config["tools"]:
+            command = TeleCasterCommand(tool)
+            command.start()
+
     def deefuzzer_start(self, conf, conf_file):
         # print(self.conf)
         self.write_conf(conf, conf_file)
@@ -165,6 +213,8 @@ class TeleCaster(Thread):
         self.deefuzzer_start(deefuzzer_global_conf, self.deefuzzer_audio_conf_file)
 
     def run(self):
+        self.audio_engine_start()
+        self.audio_tools_start()
         self.video_start()
         self.audio_start()
 
index f9c4580a659ec50d5ecd230b3553df3ee54baab7..433a826da4de2304580ab7c540153e6d7d7933e3 100755 (executable)
@@ -6,7 +6,7 @@ set -e
 #TELECASTER_PATH=/srv/telecaster/telecaster-server/
 #XDG_RUNTIME_DIR="/run/user/1000"
 
-konsole &
+konsole &
 
 # AUDIO
 
@@ -19,9 +19,9 @@ konsole &
 # qpwgraph &
 
 # JACK
-jackd $JACK_OPTIONS &
-qjackctl &
-catia &
+jackd $JACK_OPTIONS &
+qjackctl &
+catia &
 
 #sleep 2