I need to design an API in FastAPI and I am struggling to find the best way to do it.
What I need is to record a video streaming. Here is the workflow:
- User send signal to start video recording (/{camera}/start) on camera XYZ. API returns message "video recording started for camera YXZ"
- do whatever
- User send signal to stop video recording (/{camera}/stop) on camera XYZ. API returns the mp4 file of the recording.
Right now, I am using a background task to perform the video capture and a flag in the database to check if the video recording for device XYZ should continue or not. If not, the video recording is stopped, the mp4 file is saved and returned as a response for (/{camera}/stop)
Is there a more elegant way to do it? For example: avoiding using a database to store the should_continue flag, status and filename?