my proto file
syntax = "proto3";
package camera_stream;
// Camera frame message
message Frame {
bytes frame = 1;
int64 timestamp = 2;
}
// Camera stream service definition
service CameraStream {
// Method to connect and start receiving camera frames
rpc CameraStream(Empty) returns (stream Frame) {}
}
// Empty message
message Empty {}
On Saturday, 3 June 2023 at 12:32:28 UTC+5:30 Sanket Kumar Mali wrote:
> my server code
>
> camera_buffer = queue.Queue(maxsize=20)
>
> # Define the gRPC server class
> class CameraStreamServicer(camera_stream_pb2_grpc.CameraStreamServicer):
> def __init__(self):
> self.clients = []
>
> def CameraStream(self, request, context):
> global camera_buffer
> # Add the connected client to the list
> self.clients.append(context)
> try:
> while True:
> print("size: ",camera_buffer.qsize())
> frame = camera_buffer.get(timeout=1) # Get a frame
> from the buffer
>
> # Continuously send frames to the client
> for client in self.clients:
> try:
> response = camera_stream_pb2.Frame()
> response.frame = frame
> response.timestamp = int(time.time())
> yield response
> except grpc.RpcError:
> # Handle any errors or disconnections
> self.clients.remove(context)
> print("Client disconnected")
> except Exception as e:
> print("unlnown error: ", e)
>
>
> in a seperate thread I am getting frames from camera and populating the
> buffer
>
>
> On Monday, 22 May 2023 at 12:16:57 UTC+5:30 torpido wrote:
>
>> What happens if you run the same process in parallel, and serve in each
>> one a different client?
>> just to make sure that there is no issue with the bandwidth in the server.
>>
>> I would also set debug logs for gRPC to get more info
>>
>> Can you share the RPC and server code you are using? Seems like it should
>> be A *request-streaming RPC*
>> ב-יום שבת, 13 במאי 2023 בשעה 16:21:41 UTC+3, Sanket Kumar Mali כתב/ה:
>>
>>> Hi,
>>> I am trying to implement a live camera streaming setup using grpc
>>> python. I was able to stream camera frame(1280x720) in 30 fps to a single
>>> client. But whenever I try to consume the stream from multiple client it
>>> seems frame rate is getting divided (e.g if I connect two client frame rate
>>> becomes 15fps).
>>> I am looking for a direction where I am doing wrong. Appreciate any clue
>>> in the right way to achieve multi client streaming.
>>>
>>> Thanks
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/e1e02c14-2601-4598-9900-ab13a9fed2fan%40googlegroups.com.