We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 0add954 + ac757b8 commit 87480afCopy full SHA for 87480af
2 files changed
internal/modules/audiobridge/stream/mixer.go
@@ -94,6 +94,9 @@ func (m *Mixer) mixLoop() {
94
attackCoef := math.Exp(-1.0 / (sampleRate * (attackTimeMs / 1000.0)))
95
releaseCoef := math.Exp(-1.0 / (sampleRate * (releaseTimeMs / 1000.0)))
96
97
+ // Reusable zeroed chunk for sending silence
98
+ silentChunk := make([]byte, chunkSize)
99
+
100
for {
101
select {
102
case <-ticker.C:
@@ -117,6 +120,13 @@ func (m *Mixer) mixLoop() {
117
120
m.gateGain = releaseCoef * m.gateGain
118
121
}
119
122
123
124
+ // Send a chunk of silence to keep the SRT stream active
125
+ select {
126
+ case m.outChan <- silentChunk:
127
+ default:
128
+ log.Println("[AudioBridge] Warning: Mixer output channel blocked, dropping silent chunk")
129
+ }
130
continue
131
132
internal/modules/audiobridge/stream/srt.go
@@ -38,15 +38,20 @@ func (s *SRTManager) Start() error {
38
bitrate = "128k"
39
40
41
- // Setup FFmpeg command
+ // Setup FFmpeg command with options to keep connection alive
42
s.cmd = exec.Command("ffmpeg",
43
"-f", "s16le", // raw 16-bit little-endian PCM
44
"-ar", "48000", // 48kHz sample rate
45
"-ac", "2", // 2 channels (stereo)
46
"-i", "pipe:0", // Read from stdin
47
"-c:a", "libopus", // Encode to Opus
48
"-b:a", bitrate,
49
- "-f", "mpegts", // Container
+ // Apply fifo to abstract network output, adding reliability, dropped packets rather than blocking, and infinite reconnects
50
+ "-f", "fifo",
51
+ "-fifo_format", "mpegts",
52
+ "-drop_pkts_on_overflow", "1",
53
+ "-attempt_recovery", "1",
54
+ "-recovery_wait_time", "1",
55
s.cfg.Streaming.DestinationURL,
56
)
57
0 commit comments