# Stream Unity Camera to UDP address with ffmpeg

**URL:** https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944
**Category:** Audio & Video
**Tags:** Audio-Video, Question
**Created:** [July 9, 2023, 5:06pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944 "2023-07-09T17:06:29Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![nlamontagne](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@nlamontagne](https://discussions.unity.com/u/nlamontagne)
#### Post date: [July 9, 2023, 5:06pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/1 "2023-07-09T17:06:29Z")

</div>

Hello everyone,  
I’m currently working on a project where I need to stream the live video feed from a Unity camera in real-time. I have been struggling with finding the best approach to achieve this and would greatly appreciate any guidance or suggestions.

My goal is to set up a real-time video stream from my Unity camera and send it to a specific URL address. Currently, I’m using FFmpeg to start the stream, but I’m struggling with how to send the packets of my camera feed. I have a RenderTexture as the output of my camera, and I’m wondering if it’s possible to leverage the RenderTexture and send its information directly.

I have considered using Unity’s networking APIs, such as the UdpClient class, to send the video frames over UDP. However, I’m unsure about the best way to convert the RenderTexture data to a format that can be sent as UDP packets.

I have also come across WebRTC as a potential solution, but I’m not sure if it’s the right approach for my case. If anyone has experience with Unity WebRTC or other similar solutions for real-time video streaming, I would greatly appreciate your insights.

Any help or suggestion would help,  
Cheers!

---

<div class="post-metadata">

### Author: ![nlamontagne](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@nlamontagne](https://discussions.unity.com/u/nlamontagne)
#### Post date: [July 10, 2023, 2:33pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/2 "2023-07-10T14:33:23Z")

</div>

I end up using a modified version of FFmpegOut by Keijiro

> **[GitHub - fh-joanneum-research-and-design-lab/FFmpegOut at live-streaming](https://github.com/fh-joanneum-research-and-design-lab/FFmpegOut/tree/live-streaming)**
>
> live-streaming

Just need to add the Stream Camera Capture component to the camera, set the protocol and the address and it works like a charm!

---

<div class="post-metadata">

### Author: ![AllFatherGray1](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@AllFatherGray1](https://discussions.unity.com/u/AllFatherGray1)
#### Post date: [January 17, 2024, 6:21am UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/3 "2024-01-17T06:21:53Z")

</div>

> [@nlamontagne](#):
>
> I end up using a modified version of FFmpegOut by Keijiro
> 
> [https://github.com/fh-joanneum-research-and-design-lab/FFmpegOut/tree/live-streaming](https://github.com/fh-joanneum-research-and-design-lab/FFmpegOut/tree/live-streaming)
> 
> Just need to add the Stream Camera Capture component to the camera, set the protocol and the address and it works like a charm!

Can you get the stream from a non Unity source as well? I’m willing to pay for some consultation on this. PM me and we can discuss rates.

---

<div class="post-metadata">

### Author: ![nlamontagne](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@nlamontagne](https://discussions.unity.com/u/nlamontagne)
#### Post date: [January 17, 2024, 2:33pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/4 "2024-01-17T14:33:49Z")

</div>

Yes you can set the stream with a UDP protocol and then create a UDP receiver at the source that receives the data and show the stream.

---

<div class="post-metadata">

### Author: ![AllFatherGray1](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@AllFatherGray1](https://discussions.unity.com/u/AllFatherGray1)
#### Post date: [January 17, 2024, 4:54pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/5 "2024-01-17T16:54:41Z")

</div>

> [@nlamontagne](#):
>
> Yes you can set the stream with a UDP protocol and then create a UDP receiver at the source that receives the data and show the stream.

Thank you for the response! So I go to the fork and then do I make a package out of the project?  
And will this work for a non-unity receiver?

---

<div class="post-metadata">

### Author: ![nlamontagne](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@nlamontagne](https://discussions.unity.com/u/nlamontagne)
#### Post date: [January 17, 2024, 5:30pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/6 "2024-01-17T17:30:44Z")

</div>

> [@AllFatherGray\_1](#):
>
> Thank you for the response! So I go to the fork and then do I make a package out of the project?  
> And will this work for a non-unity receiver?

Yes it will work with a non-unity receiver, you can try it with OBS.

---

<div class="post-metadata">

### Author: ![AllFatherGray1](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@AllFatherGray1](https://discussions.unity.com/u/AllFatherGray1)
#### Post date: [January 17, 2024, 6:28pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/7 "2024-01-17T18:28:06Z")

</div>

> [@nlamontagne](#):
>
> Yes it will work with a non-unity receiver, you can try it with OBS.

And how would I set up a Unity receiver? Thanks so far!

---

<div class="post-metadata">

### Author: ![nlamontagne](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@nlamontagne](https://discussions.unity.com/u/nlamontagne)
#### Post date: [January 17, 2024, 6:45pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/8 "2024-01-17T18:45:02Z")

</div>

You need to create a UDP receiver, exemple here [GitHub - codemaker2015/unity-udp-demo: UDP interaction demo in Unity 3D](https://github.com/codemaker2015/unity-udp-demo)

Set the same address and port from the stream output and you should receive data coming from it. From there I’m not sure exactly what the format is but you will probably need to read the bytes and create a Texture from it. [Unity - Scripting API: Texture2D.LoadRawTextureData](https://docs.unity3d.com/ScriptReference/Texture2D.LoadRawTextureData.html)

---

<div class="post-metadata">

### Author: ![Amaru\_Signore](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Amaru\_Signore](https://discussions.unity.com/u/Amaru_Signore)
#### Post date: [February 23, 2024, 12:31pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/9 "2024-02-23T12:31:46Z")

</div>

How well will this work if I need to stream 40 cameras real time? I need to live stream 40 cameras at the same time.

---

<div class="post-metadata">

### Author: ![ZMotion\_Unity](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@ZMotion\_Unity](https://discussions.unity.com/u/ZMotion_Unity)
#### Post date: [August 2, 2024, 12:23pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/10 "2024-08-02T12:23:46Z")

</div>

Hi, thanks for sharing this tool. Could you give me a hint on how to use this with OBS? I don’t know anything about networks, what I tried was this:

I entered a UDP address as shown in the example in the Stream Camera Capture component in Unity.  
 ![image](https://europe1.discourse-cdn.com/unity/original/4X/b/6/a/b6ab3822f646e6d0686d45876a8239443ce0a96d.png)

I then played the scene in Unity, and on the same PC opened OBS and created a Browser video source and entered the same UDP address in the URL box.

 ![image](https://europe1.discourse-cdn.com/unity/original/4X/3/b/6/3b6490d5653f61f428c80bd391b3556744b25d7a.png)

Clearly that doesn’t work because I’m misunderstanding things completely. I tried searching for tutorials online but couldn’t find anything useful. Any help would be greatly appreciated!

---

<div class="post-metadata">

### Author: ![CarlBateman](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/carlbateman/32/910325_2.png) [@CarlBateman](https://discussions.unity.com/u/CarlBateman)
#### Post date: [November 28, 2024, 9:59pm UTC](https://discussions.unity.com/t/stream-unity-camera-to-udp-address-with-ffmpeg/922944/11 "2024-11-28T21:59:44Z")

</div>

I’m trying to use the Stream Camera Capture but when I use the installation links on the github page they take me to the original keijiro unity packages and I can’t work out how get the Stream Camera Capture component.  
What am I missing?
