I am trying to make a video-streaming application, in which i'll be able to both stream my webcam and my desktop. Up until now I've done so with TCP communication in order to make sure everything works, and it does, but very slowly.
I know that usually in live streams like these you would use UDP, but I can't get it to work. I have created a basic UDP client and a server, and it works with sending shorts string, but when it comes to sending a whole image i can't find a solution to that. I have also looked it up online but found only posts about sending images through sockets in general, and they used TCP.
I'm using Python 2.7, pygame to show the images, PIL + VideoCapture to save them, and StringIO + base64 in order to send them as string.
My psychic powers tell me that are hitting the size limit for a UDP packet, which is just under 64KB.   You will likely need to split your image bytes up into multiple packets when sending and have some logic to put them back together on the receiving end.  You will likely need to roll out your own header format.
Not sure why you would need to base64 encode your image bytes, that just add 33% of network overhead for no reason.
While UDP has less network overhead than TCP, it generally relies on you, the developer, to come up with your own mechanisms for flow control, fragmentation handling, lost packets, etc...
Sending an image through UDP communication