This commit is contained in:
Logan
2026-04-12 03:05:48 -04:00
parent 26d21d42e1
commit 33cad7ed24
7 changed files with 91 additions and 49 deletions
+5 -7
View File
@@ -27,15 +27,13 @@ class CallRecorder:
self._current_file = self._recordings_dir / f"{ts}_{call_id}.mp3"
self._current_call_id = call_id
# Read from the Icecast stream. burst-size=0 in icecast config ensures
# each new connection starts at the live position with no buffered data.
stream_url = f"http://{settings.icecast_host}:{settings.icecast_port}{settings.icecast_mount}"
# Record from PulseAudio (drb_sink.monitor, set as the default source).
# PulseAudio is the primary audio path — it has ~250ms latency vs 2-5s for Icecast,
# so recordings align with OP25 call_start/call_end events.
cmd = [
"ffmpeg", "-y",
"-reconnect", "1",
"-reconnect_streamed", "1",
"-reconnect_delay_max", "5",
"-i", stream_url,
"-f", "pulse",
"-i", "default",
"-acodec", "libmp3lame",
"-ar", "22050",
"-b:a", "32k",
+4 -4
View File
@@ -101,11 +101,11 @@ class RadioBot:
def _play_stream(self):
if not self._voice_client:
return
from app.config import settings
stream_url = f"http://{settings.icecast_host}:{settings.icecast_port}{settings.icecast_mount}"
# Stream from PulseAudio (drb_sink.monitor, the default source).
# ~250ms latency vs 2-5s for Icecast — stays in sync with live transmissions.
source = discord.FFmpegPCMAudio(
stream_url,
before_options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -probesize 32 -analyzeduration 0 -fflags nobuffer",
"default",
before_options="-f pulse",
)
self._voice_client.play(
discord.PCMVolumeTransformer(source, volume=1.0),