Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Video Real time video streaming

Discussion in 'Audio & Video' started by Erethan, Nov 23, 2017.

  1. Erethan

    Erethan

    Joined:
    Apr 27, 2015
    Posts:
    28
    I am developing a game where I want to stream the camera’s output from a server (which renders everything) to several clients. For simplicity, I am ignoring all audio data.

    Currently, like shown in the image below, I record the camera to a RenderTexture with 400x300 resolution, and then I encode it to JPEG, add a time stamp and send it to the client over UDP.
    JPGsolution.png


    With given resolution, my payload size varies from 13KB to 20KB so I am planning to stream over ffmpeg. However, it is not clear to me how I should tackle the problem. Are there any tutorials or other learning resources on that matter?

    As my goal is to achieve something like Gforce Now does, what strategies are available for me to use?
    Below shows what more or less I want to do:
    ffmpegSolution.png
     
  2. pilz3d

    pilz3d

    Joined:
    Mar 13, 2015
    Posts:
    9
    I am looking for the same solution, so hope someone knows...
     
  3. unity_mWFzUJMvtB3hIg

    unity_mWFzUJMvtB3hIg

    Joined:
    Dec 7, 2017
    Posts:
    1
    Hi, I am looking for the same solution too. Have you a good result ? Thx
     
  4. Erethan

    Erethan

    Joined:
    Apr 27, 2015
    Posts:
    28
    No. not yet.

    I'm still researching a solution. My current plan is to learn libavcodec(used in ffmpeg) and develop a .dll out of it but I'm getting into stuff way advanced for me.

    Progress has been quite slow :D

    Can anyone could share ideas on how to tackle the problem or have more information on real time streaming?
     
  5. thelghome

    thelghome

    Joined:
    Jul 23, 2016
    Posts:
    715
    Your UDP idea is very close to answer but I don't think it will work correctly for multiple clients. I was also looking for similar stuff but can't find any good example at that time.
    Thus, I created my own solution for my projects which are used in many public events and exhibitions. Recently, I organised all my core scripts into one single package.

    Local Live Streaming for multiple clients is one of our plugin features, please check it out.
    It also supports auto network discovery in local network.
    FM Exhibition Tool Pack
    https://assetstore.unity.com/packages/templates/packs/fm-exhibition-tool-pack-beta-143080

    As RPC and Unet system will be depreciated in future, we also added custom Network Action feature in next update v1.02

    PS: All Source Code written in C#, free to modify for specific case.

    if you need some hints, TCP will be stable & better.