# app/routes/stream.py from fastapi import APIRouter from fastapi.responses import StreamingResponse from app.services.stream_manager import stop_stream from app.services.ffmpeg_service import stream_rtsp_to_flv router = APIRouter() @router.get("/get_stream") async def get_stream(id: str): stream_output = await stream_rtsp_to_flv(id) if stream_output: return StreamingResponse(stream_output, media_type="video/x-flv") return {"message": "Unable to start RTSP to FLV conversion."} @router.get("/stop_stream") def stop(id: str): stop_stream(id) return {"message": "Stream stopped"}