'How to save or record live video feed received as bytes in django channels
I am buildings a security camera project for my finals, what i am doing is send frames from an esp32-cam to django channels websocket endpoint ws/video
I successfully manage to receive and display the video-feed.
The problem or what i am looking for is to save these bytes frames so the user can see recording of that feed and check the previous video-feed maybe consistent of 1-hour videos or something. How to do that ? and what is the best way to approch that problem ?
currently the consumer.py file looks like that
class VideoHandlerConsumer(AsyncWebsocketConsumer):
async def connect(self):
self.roomName = "video_pool"
await self.channel_layer.group_add( #create video_pool group
self.roomName,
self.channel_name
)
await self.accept()
async def disconnect(self, close_code):
await self.channel_layer.group_discard(
self.roomName,
self.channel_name
)
async def receive(self, text_data=None, bytes_data=None):
await self.channel_layer.group_send(
self.roomName,{
'type':'videoStream',
'data':bytes_data,
})
async def videoStream(self, event):
image_bytes = event['data']
# maybe start saving the frames logic here
await self.send(bytes_data=image_bytes)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
