Spaces:
Running
Running
Upload 3 files
Browse files- .gitattributes +1 -0
- Dockerfile +33 -0
- playit-linux-amd64 +3 -0
- stream_videos.py +62 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
playit-linux-amd64 filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM debian:stable
|
2 |
+
|
3 |
+
USER root
|
4 |
+
|
5 |
+
ENV DEBIAN_FRONTEND noninteractive
|
6 |
+
|
7 |
+
COPY . /app
|
8 |
+
|
9 |
+
RUN chmod -R 777 /app
|
10 |
+
|
11 |
+
WORKDIR /app
|
12 |
+
|
13 |
+
# Instala Python 3
|
14 |
+
RUN apt-get update && apt-get install -y python3
|
15 |
+
|
16 |
+
# Instala pip
|
17 |
+
RUN apt-get update && apt-get install -y python3-pip
|
18 |
+
|
19 |
+
# Instala venv
|
20 |
+
RUN apt-get update && apt-get install -y python3-venv
|
21 |
+
|
22 |
+
# Crea el entorno virtual
|
23 |
+
RUN python3 -m venv /app/venv
|
24 |
+
|
25 |
+
# Activa el entorno virtual
|
26 |
+
RUN /app/venv/bin/pip install -U pip
|
27 |
+
RUN /app/venv/bin/pip install watchdog uvicorn fastapi
|
28 |
+
|
29 |
+
# Copia el archivo stream_videos.py
|
30 |
+
COPY stream_videos.py /app/stream_videos.py
|
31 |
+
|
32 |
+
# Comando para ejecutar la aplicaci贸n
|
33 |
+
CMD ["/app/venv/bin/python", "/app/stream_videos.py"]
|
playit-linux-amd64
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66075809b4200ad006b61ec9cc707db64c2e3419c5f393410c335f38dc248266
|
3 |
+
size 5617856
|
stream_videos.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
from multiprocessing import Process
|
4 |
+
import uvicorn
|
5 |
+
from fastapi import FastAPI
|
6 |
+
import logging
|
7 |
+
import threading
|
8 |
+
import signal
|
9 |
+
import time
|
10 |
+
|
11 |
+
app = FastAPI()
|
12 |
+
|
13 |
+
# Configure logger
|
14 |
+
logging.basicConfig(level=logging.INFO)
|
15 |
+
|
16 |
+
# No Rtmp or Ffmpeg related variables
|
17 |
+
|
18 |
+
def start_playit_server():
|
19 |
+
try:
|
20 |
+
logging.info("Starting playit-linux-amd64")
|
21 |
+
subprocess.run("./playit-linux-amd64", shell=True, check=True)
|
22 |
+
except subprocess.CalledProcessError as e:
|
23 |
+
logging.error(f"Error running playit-linux-amd64: {e}")
|
24 |
+
|
25 |
+
def start_impostor_server():
|
26 |
+
try:
|
27 |
+
logging.info("Starting Impostor.Server")
|
28 |
+
subprocess.run("./hlds_linux", shell=True, check=True)
|
29 |
+
except subprocess.CalledProcessError as e:
|
30 |
+
logging.error(f"Error running Impostor.Server: {e}")
|
31 |
+
|
32 |
+
def monitor_playit_process():
|
33 |
+
while True:
|
34 |
+
if not playit_process.is_alive():
|
35 |
+
logging.info("Playit process stopped. Restarting...")
|
36 |
+
start_playit_process()
|
37 |
+
time.sleep(1) # Check every second
|
38 |
+
|
39 |
+
def start_playit_process():
|
40 |
+
global playit_process
|
41 |
+
playit_process = Process(target=start_playit_server)
|
42 |
+
playit_process.start()
|
43 |
+
|
44 |
+
@app.get("/")
|
45 |
+
async def read_root():
|
46 |
+
return {"message": "Hello World"}
|
47 |
+
|
48 |
+
if __name__ == "__main__":
|
49 |
+
# Start playit process in a separate process
|
50 |
+
start_playit_process()
|
51 |
+
|
52 |
+
# Start Impostor.Server in a separate process
|
53 |
+
global impostor_server_process
|
54 |
+
impostor_server_process = Process(target=start_impostor_server)
|
55 |
+
impostor_server_process.start()
|
56 |
+
|
57 |
+
# Start the monitor thread
|
58 |
+
monitor_thread = threading.Thread(target=monitor_playit_process)
|
59 |
+
monitor_thread.start()
|
60 |
+
|
61 |
+
# Start the FastAPI server
|
62 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|