vrillant / app.py
SorovotPelo's picture
Update app.py
4dad3a2 verified
raw
history blame contribute delete
967 Bytes
import os
import subprocess
from multiprocessing import Process
import uvicorn
from fastapi import FastAPI
app = FastAPI()
video_file = "https://huggingface.co/spaces/SorovotPelo/Lolrobo/resolve/main/badboys1latino.mp4" # Archivo de video específico
rtmp_url = "rtmp://live.twitch.tv/app/live_1104664009_xoiSdq7ayaMdFKU4xaCzkCqLw3tYvz"
ffmpeg_command = 'ffmpeg -re -i "{input}" -c:v libx264 -b:v 5000.00k -c:a aac -b:a 128.00k -preset ultrafast -f flv "{output}"'
def stream_video():
video_path = video_file
command = ffmpeg_command.format(input=video_path, output=rtmp_url)
while True:
process = subprocess.Popen(command, shell=True)
process.wait()
def start_video_streaming():
video_process = Process(target=stream_video)
video_process.start()
@app.get("/")
async def read_root():
return {"message": "Hello World"}
if __name__ == "__main__":
start_video_streaming()
uvicorn.run(app, host="0.0.0.0", port=7860)