Stream webcam via Multiplayer networking or websocket
Hi I'm looking for a solution to send my camera video to another client. I've already set up a websocket connection, so this would be one way to do it but it wouldn't be a problem to setup Unity networking. I got the webcam picture on a texture in my scene, so I think I just need the pure communication part, but I don't know where to start...
Answer by thelghome · Aug 10, 2019 at 03:38 AM
UDP/TCP Streaming & WebSocket Streaming are the most popular methods to achieve it.
I would recommend that you can try FMETP STREAM | Forum
It provides cross platform Video, Audio Streaming. and added WebSocket Streaming Demo recently. All Source Code are written in C#
Answer by Kovichenko · Nov 09, 2018 at 12:11 AM
I'm working on a project which also involves streaming video and audio. Though I'm just starting and I haven't solved this part yet.
I'm also new to Unity, so hope somebody with more knowledge can come and give better advise.
These are the steps I would follow:
1- Have a look at the WebCamTexture class. https://docs.unity3d.com/ScriptReference/WebCamTexture.html
2- I assume Unity engine can provide a texture, embedded into some structured format, an array. Though it might be serial and you might have to structure it yourself for easier handling later on.
3- You need to do some research about how to send and receive info from one device to another. One option is the official unity networking component Unet. There are other libraries in the asset Store that might work better for this.
4- Having some basic knowledge about the TCP protocol might be useful to get familiar with some terminology and understand how the networking works behind the scenes.
5- I think this should be enough to start working on the code that takes the pixel info from the camera and sends it somewhere else.
Wish you good luck! I'll be trying this soon too.
P. D.: I read again your comment and it seems you know something about websockets... I haven't used them yet so cannot comment on that.