Reduce buffering: 250ms DJ chunks, 1024-chunk preroll, X-Accel-Buffering header
This commit is contained in:
parent
43a3e692fc
commit
af109381c1
|
|
@ -2211,10 +2211,12 @@ function startBroadcast() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1000ms chunks: Dramatically reduces CPU interrupts on low-RAM machines
|
// 250ms chunks: More frequent smaller chunks reduces stall gaps on weak connections.
|
||||||
|
// A 1-second chunk creates a 1-second starvation gap if the network hiccups;
|
||||||
|
// 250ms chunks keep the server fed 4x more often.
|
||||||
// Validate state before starting
|
// Validate state before starting
|
||||||
if (mediaRecorder.state === 'inactive') {
|
if (mediaRecorder.state === 'inactive') {
|
||||||
mediaRecorder.start(1000);
|
mediaRecorder.start(250);
|
||||||
streamProcessor = mediaRecorder;
|
streamProcessor = mediaRecorder;
|
||||||
console.log('[OK] MediaRecorder started in state:', mediaRecorder.state);
|
console.log('[OK] MediaRecorder started in state:', mediaRecorder.state);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ _mp3_lock = threading.Lock()
|
||||||
_transcoder_bytes_out = 0
|
_transcoder_bytes_out = 0
|
||||||
_transcoder_last_error = None
|
_transcoder_last_error = None
|
||||||
_last_audio_chunk_ts = 0.0
|
_last_audio_chunk_ts = 0.0
|
||||||
_mp3_preroll = collections.deque(maxlen=512)
|
_mp3_preroll = collections.deque(maxlen=1024) # ~83s at 96kbps for fast reconnect buffer fill
|
||||||
|
|
||||||
|
|
||||||
def _start_transcoder_if_needed(is_mp3_input=False):
|
def _start_transcoder_if_needed(is_mp3_input=False):
|
||||||
|
|
@ -486,6 +486,7 @@ def setup_shared_routes(app, index_file='index.html'):
|
||||||
'X-Content-Type-Options': 'nosniff',
|
'X-Content-Type-Options': 'nosniff',
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Icy-Name': 'TechDJ Live',
|
'Icy-Name': 'TechDJ Live',
|
||||||
|
'X-Accel-Buffering': 'no', # Tell nginx/Cloudflare not to buffer this stream
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.route('/stream_debug')
|
@app.route('/stream_debug')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue