0

I have the following code sending frames from the client to the server. I am unable to receive complete frames from the client to the server. Sometimes I receive on the server-side 1888 frames sometimes 2000 frames, the total frames are 2522.

Client.py

context = zmq.Context()
footage_socket = context.socket(zmq.PUB)
footage_socket.connect('tcp://localhost:9999')
videoFile = "E:/sample.mp4"
camera = cv2.VideoCapture(videoFile) 
count = 0
while True:
  grabbed, frame = camera.read()
  count += 1
  print(count)
  try:
      frame = cv2.resize( frame, (224, 224) )
  except cv2.error:
      break
  encoded, buffer = cv2.imencode('.jpg', frame)
  jpg_as_text = base64.b64encode(buffer)
  footage_socket.send(jpg_as_text)

Server.py

context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
footage_socket.bind('tcp://*:9999')
footage_socket.setsockopt_string(zmq.SUBSCRIBE, np.unicode(''))
count = 0
while True:
    frame = footage_socket.recv_string()
    count += 1
    print(count)

Thanks, help is highly appreciated.

Mazia
  • 63
  • 1
  • 10
  • Does this answer your question? [Python socket not receiving without sending](https://stackoverflow.com/questions/43420075/python-socket-not-receiving-without-sending) – President James K. Polk Nov 05 '20 at 15:24
  • @PresidentJamesK.Polk, thanks for this, I will have a look at this . Once again thank you for your wonderful support – Mazia Nov 05 '20 at 15:26

0 Answers0