Spaces:
Sleeping
Sleeping
Update stream_audio.py
Browse files- stream_audio.py +3 -3
stream_audio.py
CHANGED
|
@@ -4,7 +4,6 @@ import subprocess
|
|
| 4 |
from multiprocessing import Process
|
| 5 |
from fastapi import FastAPI, Response
|
| 6 |
from fastapi.responses import HTMLResponse
|
| 7 |
-
from fastapi.staticfiles import StaticFiles
|
| 8 |
import uvicorn
|
| 9 |
|
| 10 |
app = FastAPI()
|
|
@@ -14,16 +13,17 @@ audio_file = "/app/theforgottenradio.mp3"
|
|
| 14 |
hls_output = "/app/stream.m3u8"
|
| 15 |
hls_segment_prefix = "/app/stream"
|
| 16 |
|
| 17 |
-
# Comando FFmpeg para transmitir audio en HLS
|
| 18 |
ffmpeg_command = [
|
| 19 |
'ffmpeg',
|
| 20 |
'-re',
|
|
|
|
| 21 |
'-i', audio_file,
|
| 22 |
'-c:a', 'aac',
|
| 23 |
'-b:a', '128k',
|
| 24 |
'-f', 'hls',
|
| 25 |
'-hls_time', '10',
|
| 26 |
-
'-hls_list_size', '
|
| 27 |
'-hls_flags', 'delete_segments',
|
| 28 |
'-hls_segment_filename', f'{hls_segment_prefix}%d.ts',
|
| 29 |
hls_output
|
|
|
|
| 4 |
from multiprocessing import Process
|
| 5 |
from fastapi import FastAPI, Response
|
| 6 |
from fastapi.responses import HTMLResponse
|
|
|
|
| 7 |
import uvicorn
|
| 8 |
|
| 9 |
app = FastAPI()
|
|
|
|
| 13 |
hls_output = "/app/stream.m3u8"
|
| 14 |
hls_segment_prefix = "/app/stream"
|
| 15 |
|
| 16 |
+
# Comando FFmpeg para transmitir audio en HLS en bucle
|
| 17 |
ffmpeg_command = [
|
| 18 |
'ffmpeg',
|
| 19 |
'-re',
|
| 20 |
+
'-stream_loop', '-1', # Repetir indefinidamente el audio
|
| 21 |
'-i', audio_file,
|
| 22 |
'-c:a', 'aac',
|
| 23 |
'-b:a', '128k',
|
| 24 |
'-f', 'hls',
|
| 25 |
'-hls_time', '10',
|
| 26 |
+
'-hls_list_size', '10', # Mantener solo los últimos 10 segmentos en la lista de reproducción
|
| 27 |
'-hls_flags', 'delete_segments',
|
| 28 |
'-hls_segment_filename', f'{hls_segment_prefix}%d.ts',
|
| 29 |
hls_output
|