Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
| 4 |
-
import pyautogui
|
| 5 |
import subprocess
|
| 6 |
import threading
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def start_streaming(service, stream_key):
|
| 9 |
# Ocultar la clave de transmisi贸n
|
| 10 |
hidden_key = '*' * len(stream_key)
|
|
@@ -17,9 +21,9 @@ def start_streaming(service, stream_key):
|
|
| 17 |
else:
|
| 18 |
return "Servicio no soportado"
|
| 19 |
|
| 20 |
-
# Configurar la captura de pantalla
|
| 21 |
-
screen_width, screen_height =
|
| 22 |
-
|
| 23 |
# Configurar FFmpeg para la transmisi贸n
|
| 24 |
command = [
|
| 25 |
'ffmpeg',
|
|
@@ -39,18 +43,16 @@ def start_streaming(service, stream_key):
|
|
| 39 |
|
| 40 |
def stream_screen():
|
| 41 |
while True:
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
frame = np.array(screenshot)
|
| 45 |
-
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
|
| 46 |
|
| 47 |
# Enviar el frame a FFmpeg
|
| 48 |
process.stdin.write(frame.tobytes())
|
| 49 |
|
| 50 |
# Iniciar el streaming en un hilo separado
|
| 51 |
-
threading.Thread(target=
|
| 52 |
|
| 53 |
-
return f"Transmisi贸n iniciada en {service} (Clave: {hidden_key})"
|
| 54 |
|
| 55 |
# Crear la interfaz de Gradio
|
| 56 |
iface = gr.Interface(
|
|
@@ -60,8 +62,8 @@ iface = gr.Interface(
|
|
| 60 |
gr.Textbox(type="password", label="Clave de transmisi贸n")
|
| 61 |
],
|
| 62 |
outputs="text",
|
| 63 |
-
title="
|
| 64 |
-
description="Selecciona tu servicio de transmisi贸n, ingresa tu clave y
|
| 65 |
)
|
| 66 |
|
| 67 |
# Iniciar la interfaz de Gradio
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
import subprocess
|
| 5 |
import threading
|
| 6 |
|
| 7 |
+
def create_dummy_frame(width, height):
|
| 8 |
+
# Crear un frame de ejemplo
|
| 9 |
+
frame = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
|
| 10 |
+
return frame
|
| 11 |
+
|
| 12 |
def start_streaming(service, stream_key):
|
| 13 |
# Ocultar la clave de transmisi贸n
|
| 14 |
hidden_key = '*' * len(stream_key)
|
|
|
|
| 21 |
else:
|
| 22 |
return "Servicio no soportado"
|
| 23 |
|
| 24 |
+
# Configurar la captura de pantalla simulada
|
| 25 |
+
screen_width, screen_height = 1280, 720 # Tama帽o de ejemplo
|
| 26 |
+
|
| 27 |
# Configurar FFmpeg para la transmisi贸n
|
| 28 |
command = [
|
| 29 |
'ffmpeg',
|
|
|
|
| 43 |
|
| 44 |
def stream_screen():
|
| 45 |
while True:
|
| 46 |
+
# Crear un frame de ejemplo
|
| 47 |
+
frame = create_dummy_frame(screen_width, screen_height)
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Enviar el frame a FFmpeg
|
| 50 |
process.stdin.write(frame.tobytes())
|
| 51 |
|
| 52 |
# Iniciar el streaming en un hilo separado
|
| 53 |
+
threading.Thread(target=stream_stream, daemon=True).start()
|
| 54 |
|
| 55 |
+
return f"Transmisi贸n simulada iniciada en {service} (Clave: {hidden_key})"
|
| 56 |
|
| 57 |
# Crear la interfaz de Gradio
|
| 58 |
iface = gr.Interface(
|
|
|
|
| 62 |
gr.Textbox(type="password", label="Clave de transmisi贸n")
|
| 63 |
],
|
| 64 |
outputs="text",
|
| 65 |
+
title="Simulaci贸n de transmisi贸n en vivo",
|
| 66 |
+
description="Selecciona tu servicio de transmisi贸n, ingresa tu clave y simula una transmisi贸n en vivo."
|
| 67 |
)
|
| 68 |
|
| 69 |
# Iniciar la interfaz de Gradio
|