我写了下面的代码在GRPC上传输视频。Im使用客户端流媒体。客户端通过流以帧形式发送视频。每个帧被转换为字节数据类型并被传输。在
但我的视频播放速度比实际速度慢。如何确保视频以实际速度播放?在
图像测试.proto文件syntax = "proto3";
option java_multiple_files = true;
option objc_class_prefix = "HLW";
// The greeting service definition.
service ImageTest {
// Sends a greeting
rpc Analyse (stream MsgRequest) returns (MsgReply) {}
}
// The request message containing the image.
message MsgRequest {
bytes img = 1;
}
// The response message containing the reply
message MsgReply {
int32 reply = 1;
}
图像测试_服务器.py
^{pr2}$
图像测试_客户端.pydef run():
channel = grpc.insecure_channel('localhost:50051')
stub = imageTest_pb2_grpc.ImageTestStub(channel)
response = stub.Analyse( generateRequests() )
def generateRequests():
videogen = skvideo.io.vreader(URL)
for frame in videogen:
frame = cv2.cvtColor( frame, cv2.COLOR_RGB2GRAY )
frame = bytes(frame)
yield imageTest_pb2.MsgRequest(img= frame)
if __name__ == '__main__':
run()