CineMax commited on
Commit
f8a7cdd
·
verified ·
1 Parent(s): 5efd6a0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import subprocess
3
+ import json
4
+
5
+ app = FastAPI()
6
+
7
+ @app.get("/extraer-audios")
8
+ def extraer_audios(url: str):
9
+ # Comando FFprobe para leer la URL del MP4 desde tu hosting
10
+ comando = [
11
+ "ffprobe", "-v", "quiet", "-print_format", "json",
12
+ "-show_streams", url
13
+ ]
14
+
15
+ resultado = subprocess.run(comando, capture_output=True, text=True)
16
+ datos = json.loads(resultado.stdout)
17
+
18
+ audios = []
19
+ if "streams" in datos:
20
+ for stream in datos["streams"]:
21
+ if stream.get("codec_type") == "audio":
22
+ audios.append({
23
+ "id": stream.get("index"),
24
+ "idioma": stream.get("tags", {}).get("language", "Desconocido")
25
+ })
26
+
27
+ return {"audios": audios}