Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Stream Unity Camera to UDP address with ffmpeg

Discussion in 'Audio & Video' started by nlamontagne, Jul 9, 2023.

  1. nlamontagne

    nlamontagne

    Joined:
    Feb 2, 2022
    Posts:
    5
    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!
     
  2. nlamontagne

    nlamontagne

    Joined:
    Feb 2, 2022
    Posts:
    5
  3. AllFatherGray

    AllFatherGray

    Joined:
    Nov 29, 2014
    Posts:
    17
    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.
     
  4. nlamontagne

    nlamontagne

    Joined:
    Feb 2, 2022
    Posts:
    5
    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.
     
  5. AllFatherGray

    AllFatherGray

    Joined:
    Nov 29, 2014
    Posts:
    17
    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?
     
  6. nlamontagne

    nlamontagne

    Joined:
    Feb 2, 2022
    Posts:
    5
    Yes it will work with a non-unity receiver, you can try it with OBS.
     
    AllFatherGray likes this.
  7. AllFatherGray

    AllFatherGray

    Joined:
    Nov 29, 2014
    Posts:
    17
    And how would I set up a Unity receiver? Thanks so far!
     
  8. nlamontagne

    nlamontagne

    Joined:
    Feb 2, 2022
    Posts:
    5
  9. Amaru_Signore

    Amaru_Signore

    Joined:
    Jul 3, 2023
    Posts:
    1
    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.