Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Official Unity Render Streaming Introduction & FAQ

Discussion in 'Unity Render Streaming' started by kazuki_unity729, Sep 10, 2019.

  1. RocketPixel

    RocketPixel

    Joined:
    Jun 23, 2020
    Posts:
    5
    Thank you for your reply. Would this require changes from the unity engine or do you think it’s possible to integrate directly?
     
  2. princemioRocker

    princemioRocker

    Joined:
    Apr 1, 2020
    Posts:
    3
    Hey guys,

    i wanted to ask about the general plans of WebRTC @Unity. Since a couple of month there is an unstable version with varying quality - new feautures that then get reverted (SDP) and input stutter appearing. Unreal on the other hand is stable and production ready since a year. On Github i can see Kazuki doing an amazing job working very hard on new and old issues. But it looks like this Dev is alone with EVERY Bug of quite a complex technology. Is there anyone else at Unity who can support? So my general question is - what are the future plans of unity to invest into this technology.
     
  3. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    I'm still stacked with this issue, I did give up but then I saw this video and I am starting to ask myself If I did something wrong. I noticed that also in the example for URP the camera is rendering blue, but we don't notice because the stream is made from the other two cameras.

    Any idea or suggestion on how to fix this?
     
  4. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    Is the scaleResolutionDownBy parameter inside RTCRtpEncodingParameters already supported?
    When I set this parameter below one I get an invalid range error.
    Setting it above one results in the image being frozen, the input does still get transmitted.
     
  5. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    I have a situation where I am dynamically loading cameras when a client connects to the session. Typically the RTCPeerConnection has video / audio tracks that already are registered added to it during the OnOffer in RenderStreaming.cs. Now I want to add a new video track to an existing RTCPeerConnection. I have tried a number of variations but, the documentation (link below) says to add the track and then CreateAnswer. Do I need to then use the m_signaling to SendAnswer?

    https://docs.unity3d.com/Packages/com.unity.webrtc@2.1/manual/videostreaming.html

    Thank you
     
  6. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    Could you tell me more detail your issue?
    - OS
    - Graphics API
    - Unity version
    - Package version (latest webrtc package version is 2.1.3-preview)
     
  7. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    I am afraid the "scaleResolutionDownBy" parameter is not work when using Hardware encoder.
     
    Lukas_Kastern likes this.
  8. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    Generally you need to renegotiate between two peers after the other track added.
    You can read an example code which is the pattern provided by W3C.
    https://w3c.github.io/webrtc-pc/#perfect-negotiation-example

    This pull request is for implementing renegotiation process. This feature will be released next version.
    https://github.com/Unity-Technologies/UnityRenderStreaming/pull/334/files
     
  9. pandaizzle

    pandaizzle

    Joined:
    Sep 1, 2020
    Posts:
    3
    What is the state of WebRTC @Unity for mac? I would like to use the pattern from the MediaStream sample but I noticed in the documentation that Unity WebRTC requires a NVDIA graphics card. Is there currently a way to make this work and if not, is it on the roadmap?
     
  10. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    We have developers on our team developing on the Mac. Use the latest Unity WebRTC 2.1.3 and make sure you use Software encoding. If you do have a Nvidia card in your Mac you can use the Hardware encoding. Good luck and happy streaming.
     
  11. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Hello, I want to know how to set the encoding frame rate?
     
  12. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    In the latest version 2.1.3 (could be in an earlier version but, I have not checked). When using AddTrack on RTCPeerConnection it will return a RTCRtpSender. Using 'GetParameters' 'SetParameters' you can get access to the RTCRtpEncodingParameters.

    It gives you access to encoding settings where you can set min/max bitrate and framerate.

    https://docs.unity3d.com/Packages/com.unity.webrtc@2.1/api/Unity.WebRTC.RTCRtpSender.html
    https://docs.unity3d.com/Packages/c...pi/Unity.WebRTC.RTCRtpEncodingParameters.html
     
  13. fourbb

    fourbb

    Joined:
    Jul 22, 2020
    Posts:
    13
    Thank you for your reply. It was very useful to me.
     
  14. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    - OS =Windows 10
    - Graphics API = Auto Graphics API for WIndows
    - Unity Version = 2019.4.10f
    - Package version = 2.1.1 preview

    Repro steps:
    --> Make a project with unity render streaming and import the URP package
    --> Add XR Interaction Toolkit and XR Interaction Toolkit management
    --> In Project Settings under XR Plugin Management add Oculus
    --> Open the sample scene and add an XR Rig room scale then press play

    This will enable you to use the controllers and the headset as inputs that can be seen also in the web, but nothing from the local server through the hmd that will show you a blue screen.
    Playing with the Rendering Priority in the Camera of the Rendering Streaming Camera I was able to see something also in the hmd camera ( from the hmd), but I see myself from a third point of view like in the picture below.

    My problem is that I don't want just to be able to see correctly from the server ( through the hmd) but to use also the hmd from the web, do you think I can achieve this in some way with this package?


    View from the game window in the server unity editor : render_result.png
     
  15. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    We have been successfully using Unity Render Streaming to setup our own platform (front end, database, session management, link automation, regions, cost management ...) for streaming our applications. We currently use AWS instances with Tesla T4 cards, with differing memory configurations. (see Nvidia support grid below)

    https://developer.nvidia.com/video-encode-decode-gpu-support-matrix

    The next big issue we are attempting to address is quality of our streams. We are tweaking the following data values:
    • Render Texture size (720p to 1080p). we are not looking to do 4K at this point.
    • Bitrates (x-google-start-bitrate and x-google-max-bitrate) using SDP munging.
    I am currently updating to the latest version (com.unity.webrtc 2.1.3 and integrating UnityRenderStreaming latest changes). We are removing the SDP munging and going to use the RTCRtpSender Get/SetParameters logic to set:
    • RTCRtpEncodingParameters - Frame Rate
    • RTCRtpEncodingParameters - Min Bit Rate
    • RTCRtpEncodingParameters - Max Bit Rate
    Considering we are attempting to maximize the quality and number of streams:
    • Are there other settings we can tweak to manage encoding settings, quality and performance?
    • Do we have more low level control of encoding hardware?
    • Besides chrome://webrtc-internals/ are there other tools to measure quality?
    • We have situations where the quality is fine and we get periods of corruption, do you have suggestions on how to handle dynamic changes in output?
    Thank you for all your work, we realize there is not a large team behind this effort.
     
    kayy likes this.
  16. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    I am afraid we have never tested streaming feature on VR yet. This is new attempt for ours.
    I guess this issue is occuerred by browser. Which browser do you use on Oculus?
     
  17. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    We recognize there are many issue about video quality and stability.
    Now, `RTCRtpEncodingParameters` that is all we can manage settings. In the near future we will add APIs to select codec and profile.

    No, we don't provide the features to control settings of hardware encoder.

    We developed Stats C# API and statistics tool.
    https://docs.unity3d.com/Packages/com.unity.webrtc@2.1/manual/statistics.html
    https://docs.unity3d.com/Packages/com.unity.webrtc@2.1/manual/webrtcstats.html
    Basically, libwebrtc tunes video quality automatically following bitrate.
    I guess it is related this issue. we are focusing on fixing it.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/205
     
  18. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    Thank you for the response. I am going down the path of making a branched version of the native plugin, giving us control of the NVENC settings, I am sure it is one of the efforts that are happening on your side. Looking forward to any future improvements you make. If I make strides with this effort I will share my findings with the forum.

    If you have any recommendations or suggestions, my first approach will be exposing the nvEncInitializeParams setup in NvEncoder.cpp. Want to be able to flip between the various encoders (H264 and HEVC) and available presets.

    Thank you for all your efforts and help.
     
  19. LazyOnion

    LazyOnion

    Joined:
    Mar 6, 2018
    Posts:
    22
    Is it possible to adaptively change the resolution or the bitrate?
     
  20. jalemanyf

    jalemanyf

    Joined:
    Jun 16, 2013
    Posts:
    25
  21. bubble8773

    bubble8773

    Joined:
    Feb 4, 2017
    Posts:
    2
    My Unity is crashing after playing the Render streaming project.
     
  22. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    Have you checked this template project?
    https://github.com/Unity-Technologi...derstreaming-hd/Documentation~/en/tutorial.md
     
  23. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
  24. jalemanyf

    jalemanyf

    Joined:
    Jun 16, 2013
    Posts:
    25
    Hi kazuki,

    I tried but i can't follow well the instructions:

    I have installed de WebRTC 2.1.3 preview packege on Unity 2019.4.12f1 without problems but...:

    -I can't find the 2 templates to copy on the directory...

    -I don't have the menú option "Render Streaming / Download web App".

    Which step I have missed?

    Thanks in advance,
     
    keeponshading likes this.
  25. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    We have been more successful using VP8 (software encoding) as of late. The new issue we get with it is the start bitrate is extremely low and the ramp up time to something reasonable can be a minute or more. I have read the default start bit rate for VP8 is 20 kbps.

    Do we have access to modifying the start / min / max on software encoding?
    Would SDP munging be the better route? Has anyone had success with tweaking software encoding settings?

    Looking at the native plugin I see that function on the software encoder has no implementation.

    Thanks again for all your work.
     
  26. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    This is a right place to download templates.
    https://github.com/Unity-Technologies/UnityRenderStreaming/releases/tag/2.1.1-preview

    I found that the link points different place. I'll apologize and correct that.
     
  27. jalemanyf

    jalemanyf

    Joined:
    Jun 16, 2013
    Posts:
    25
    Hi kazuki,

    Thanks for your quick response.

    I could complete correctly the next step! Yeaaaah!!! but..:

    1.-The menu option "Edit / Render Streaming / Download web app" never could be completed. Always give me an "Input string was not in a correct format". With a new folder or an old folder the system don't recognise it. I'm doing in windows 10.

    2.-The option "Edit / Render Streaming / Show web app documentation" returns an 404 error. It seems the link is broken.

    ( Now, I'm going to download the web server.exe from the same place of the templates and run the node project from the shell prompt. )

    Sorry for the inconvenience. Thanks a lot for your help! I think your project is really interesting ;)

    King Regards
     
    kazuki_unity729 likes this.
  28. jalemanyf

    jalemanyf

    Joined:
    Jun 16, 2013
    Posts:
    25
    Hi Kazuki,

    I done it! Works like a charm!!!

    I downloaded the server from the same place of the templates and just jumped the menus steps of the tuttorial, directly run the server and changing the IP address on the script!

    If you want, I can translate the documentation to spanish ( if it helps you to get more public ).

    Now, I have to see how to implement in my project ;)

    Thanks for all and have a nice weekend.
     
  29. OLGV

    OLGV

    Joined:
    Oct 4, 2012
    Posts:
    57
    all in all... but how do you run the
    webserver_mac
    ? ...on Mac obviously :|
     
  30. subjectdenied

    subjectdenied

    Joined:
    Jan 3, 2016
    Posts:
    6
    you have to make it executable before you can run it, to do so change directory to where the file is and:

    chmod +x ./webserver_mac
    ./webserver_mac

    that opens the webserver for port 80, if you want to use another port (on linux for an example, i cant use 80, so i need to set 8000 or similar), you have to set the port in the rendersettings in the project, and also add -p <port-number> when running the webserver
     
    OLGV likes this.
  31. OLGV

    OLGV

    Joined:
    Oct 4, 2012
    Posts:
    57
  32. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi,

    i installed the Template
    com.unity.template.renderstreaming-rtx-2.1.1-preview.tgz
    to
    <Unity Editor Root>/Data/Resources/PackageManager/ProjectTemplates

    Downloaded manually the webserver to a desktop location and started the webserver.exe.

    because Edit/Render Streaming/Download web app is broken and end in an file browser window you cannot close anymore.

    Then i started the example scene but there is no streaming in the browser windows.

    The only error i see is
    Assertion failed on expression: 'sceneRanges.empty()'

    Do you have an idea what´s wrong here?
    I tried to catch all needed info in the screenshot.

    TEST_RenderStreaming.JPG
     
  33. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937

    I aslo downladed manualy the web server.exe.

    Can you explain this step you did ?
    "run the node project from the shell prompt"
     
  34. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
  35. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    76
    Hi, I share workaround about using UnityUI on UnityRenderStreaming.

    We have problem below using UnityUI.
    This workaround is avoid this problem.
    Working UnityUI in Unity application is background.

    After replace with `InputSystemUIInputModule` in the `StandaloneInputModule` that is attached to the same object as the `EventSystem` component.

    please follow steps below

    1. Update `com.unity.inputsystem` to `1.1.0-preview2` on PackageManager.

    2. In ProjectSetting->Player->OtherSetting, check `Allow unsafe code`.

    3. Replace the floowing Component with `EventSystem` on the Scene.
    Code (CSharp):
    1. using UnityEngine.EventSystems;
    2. using UnityEngine.InputSystem;
    3. using UnityEngine.InputSystem.LowLevel;
    4. public class CustomEventSystem : EventSystem
    5. {
    6.     protected override void Awake()
    7.     {
    8.         base.Awake();
    9.         unsafe
    10.         {
    11.             InputSystem.onDeviceCommand += InputSystemOnDeviceCommand;
    12.         }
    13.     }
    14.     private static unsafe long? InputSystemOnDeviceCommand(InputDevice device, InputDeviceCommand* command)
    15.     {
    16.         if (command->type != QueryCanRunInBackground.Type)
    17.         {
    18.             // return null is skip this evaluation
    19.             return null;
    20.         }
    21.         ((QueryCanRunInBackground*)command)->canRunInBackground = true;
    22.         return InputDeviceCommand.GenericSuccess;
    23.     }
    24.     protected override void OnApplicationFocus(bool hasFocus)
    25.     {
    26.         //Do not change focus flag on eventsystem
    27.     }
    28. }

    4. (Optional) For UnityEditor, Open Window->Analysis->InputDebugger and turn on `Lock Input to Game View` in Options.
     
    kayy and Maktech like this.
  36. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Hi, is there a way to set custom headers for the socket connection? I want to send an authentication token with it which I can't seem to find a way to do
     
  37. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Thanks a lot, that did the job.
    I leave this here because it s not self explainig.)

    I installed
    nmp from
    https://www.npmjs.com/get-npm

    and startet
    UnityRenderStreaming/test_webapp

    The compiled webserver.exe did not work for me.


    Unbenannt.JPG
     
  38. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    The feature to customize header of the socket connection is not provided by our package.
    You need to implement the feature yourself in the web application and WebSocketSignaling class.

    https://github.com/Unity-Technologi...ssets/Scripts/Signaling/WebSocketSignaling.cs
    https://github.com/Unity-Technologi...ob/develop/WebApp/public/scripts/signaling.js
     
  39. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    Please try

    npm run dev -- -p 8080
     
  40. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101

    Thanks for the response. I checked the WebSocketSignaling class and apparently WebSocket class only lets me set the cookie. There is no option to add headers, would I possibly need to try other socket library?
     
  41. pandaizzle

    pandaizzle

    Joined:
    Sep 1, 2020
    Posts:
    3
    Hi! I'm trying to figure out how to use the WebRTC Plugin (without streaming) to receive audio and video from a URL stream using the software encoder.

    I'm trying to use the MediaStream sample from 2.2.0-preview, but when I switch it to use the software encoder, I get exceptions such as the following:

    Error Detail Type: Failed to set remote offer sdp: Called in wrong state: kHaveLocalOffer
    UnityEngine.Debug:LogError(Object)
    MediaStreamSample:OnSetSessionDescriptionError(RTCError&) (at Assets/Samples/WebRTC/2.2.0-preview/Example/MediaStreamSample.cs:284)
    <OnCreateOfferSuccess>d__39:MoveNext() (at Assets/Samples/WebRTC/2.2.0-preview/Example/MediaStreamSample.cs:253)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


    Error Detail Type: PeerConnection cannot create an answer in a state other than have-remote-offer or have-local-pranswer.
    UnityEngine.Debug:LogError(Object)
    MediaStreamSample:OnCreateSessionDescriptionError(RTCError) (at Assets/Samples/WebRTC/2.2.0-preview/Example/MediaStreamSample.cs:327)
    <OnCreateOfferSuccess>d__39:MoveNext() (at Assets/Samples/WebRTC/2.2.0-preview/Example/MediaStreamSample.cs:268)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    Is this scenario currently supported with the software encoder right now? I already have a WebRTC Server set up (with a url) that I'm trying to receive a stream from. I would really appreciate guidance on what I need to use and implement to properly receive the stream using the WebRTC plugin in its current state.
     
  42. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    I guess websocket protocol do not provide the headers.
    This page might be useful for you.
    https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api
     
  43. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    Could you tell me which platform are you using?
    If you have a minimum project for reproducing the issue, we can investigate it.
     
  44. pandaizzle

    pandaizzle

    Joined:
    Sep 1, 2020
    Posts:
    3
    I'm using Windows 10 Enterprise with Unity Version: 2019.4.2f1.
     
  45. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    I guess it should work well, Do you have a code to reproduce this error?
     
  46. aktameemi

    aktameemi

    Joined:
    Jul 26, 2017
    Posts:
    2
    Hello everyone, could please anyone advise on the following error?
    Error Detail Type: Failed to set remote answer sdp: Failed to set remote video description send parameters for m-section with mid='1'.
     
  47. aktameemi

    aktameemi

    Joined:
    Jul 26, 2017
    Posts:
    2
    Also, is there example of how to play an audio with AudioStreamTrack?
     
  48. Dev_Sebas

    Dev_Sebas

    Joined:
    Jul 10, 2014
    Posts:
    19
    Hi,
    Very pleased to see Unity implementing open platforms, like WebRTC. Is there any estimated time for iOS support?
    Thanks in advance,
     
  49. thedrhax14

    thedrhax14

    Joined:
    Aug 7, 2014
    Posts:
    38
    Hi,
    Is it possible to use Unity WebRTC as client on a unity app and built for WebGL, iOS and Android?
     
  50. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    803
    We know that many users wants the supporting for additional platforms.
    You can read this page written by users about that.
    https://github.com/Unity-Technologies/com.unity.webrtc/issues/15

    In our plan we will support iOS platform in the end of this year.