This commit is contained in:
awe
2025-11-21 16:31:38 +03:00
parent 49a54616b9
commit eeec3582c9
2 changed files with 12 additions and 8 deletions

View File

@ -294,9 +294,11 @@ async def stream_video_from_fifo():
# -c:v copy: copy video codec without re-encoding (use hardware-encoded H.264)
# -f hls: output HLS format
# -hls_time 1: 1 second per segment (low latency)
# -hls_list_size 5: keep 5 segments in playlist
# -hls_list_size 10: keep 10 segments in playlist (more buffer for clients)
# -hls_delete_threshold 3: delete segments only after 3 new ones created
# -hls_flags delete_segments+append_list+omit_endlist: live streaming flags
# -hls_segment_type mpegts: use MPEG-TS segments
# -hls_segment_filename: use %d for unlimited numbering
# -start_number 0: start segment numbering from 0
ffmpeg_process = subprocess.Popen(
['ffmpeg',
@ -308,10 +310,11 @@ async def stream_video_from_fifo():
'-c:v', 'copy',
'-f', 'hls',
'-hls_time', '1',
'-hls_list_size', '5',
'-hls_list_size', '10',
'-hls_delete_threshold', '3',
'-hls_flags', 'delete_segments+append_list+omit_endlist',
'-hls_segment_type', 'mpegts',
'-hls_segment_filename', f'{hls_dir}/segment_%03d.ts',
'-hls_segment_filename', f'{hls_dir}/segment_%d.ts',
'-start_number', '0',
f'{hls_dir}/playlist.m3u8'],
stdin=subprocess.PIPE,

View File

@ -367,13 +367,14 @@
if (Hls.isSupported()) {
hls = new Hls({
// Low latency configuration
// Low latency configuration with increased buffer
lowLatencyMode: true,
backBufferLength: 90,
maxBufferLength: 3,
maxBufferSize: 1 * 1024 * 1024, // 1MB
liveSyncDurationCount: 1,
liveMaxLatencyDurationCount: 2,
maxBufferLength: 10, // Increased from 3 to 10 seconds
maxBufferSize: 3 * 1024 * 1024, // Increased from 1MB to 3MB
liveSyncDurationCount: 3, // Keep 3 segments in sync
liveMaxLatencyDurationCount: 5, // Max 5 segments latency before catchup
maxMaxBufferLength: 30, // Maximum buffer length
enableWorker: true,
debug: false
});