-
Notifications
You must be signed in to change notification settings - Fork 283
can Support customize local Video source in Unity like renderTexture? #35
Comments
Hi @raiscui
I appreciate these are not great answers, and there is no way currently to do any of that without modifying the code of MixedReality-WebRTC and/or the code of the WebRTC UWP project. If you want to give it a try however and submit a PR for that then we can talk about how to proceed. |
Quick update - Azure Kinect doesn't work out of the box because it has a 7-microphone array, and WebRTC internally only supports audio capture devices with 4 channels. This is a problem with the Google implementation: https://bugs.chromium.org/p/webrtc/issues/detail?id=10881 |
Also important note @raiscui, just plugging in Azure Kinect on your PC will break WebRTC initializing, even if you don't plan to use it. And this is again due to Google's implementation and closed as "By Design": |
Any news on item 1, @djee-ms ? I am doing some custom rendering on Windows application and would like to stream ARGB frames to Unity. As far as I can tell, I can't use any other video source than the webcam. |
+1 for this feature. |
Perhaps the frames could be sent as raw pixels through a datachannel? We'd miss compression though. |
@jahnotto no there is a much better way with a custom video source. I too would really like to see that feature. Unfortunately we're currently quite busy with the v1.0 release planned for the end of the month, and some blockers like #74. I will see if I have some spare cycles to push a rough implementation, even partial, but I cannot promise you anything quite yet. |
Ok, thanks! Looking forward to getting a custom video source. Meanwhile, I'll use a DataChannel just for prototyping. |
If anyone else is interested: as a temporary workaround, I am using a DataChannel to send the frames from a Windows desktop application to a Unity (HoloLens) app. It's very slow, and the messages are split into multiple sub messages that need to be aggregated on the HoloLens. It works for prototyping a solution though :) Looking forward to a proper custom video source implementation. @djee-ms , would you like me to create a new enhancement issue for a custom video source, or should we just use this issue? |
No I think we can leave that issue open for the custom video source enhancement, the title and discussion are relevant. |
In my temporary workaround using a datachannel, only a few frames are received if I send them too often (like every 100 ms). It almost seems like the message bus is flooded. If I send the messages only once per second, it works fine. Is this to be expected? |
Did you check the buffering of data channels? I didn't try myself but I know that the internal data channel buffer can get saturated if you try to send faster than it can handles, and in that case calls to MixedReality-WebRTC/libs/Microsoft.MixedReality.WebRTC.Native/src/data_channel.h Lines 51 to 59 in 59df5a1
Unfortunately I just noticed that on the C# side the |
Thanks again -- I will try that! |
I pushed a change that should help, which exposes an event publicly, and ensures an exception is thrown if trying to send too fast. See 1bc2ca6. |
I am indeed getting an exception when I send too fast. The BufferingChanged event is never fired though. |
+1 |
+1 |
Soon! This is on the roadmap for the next 1.1 release, hopefully by the end of the month or so, and there's already some work done for it. Need a few bug fixes, and some more testing and polish now before it's ready to be committed. |
As requested by @djee-ms on the mixedreality-webrtc Slack channel, I'll describe our use case here: We are doing raycast volume rendering for a HoloLens 2. As the HoloLens is not powerful enough for this type of rendering, we are doing remote rendering on a PC. Some definitions used in this solution: The desired data flow is as follows:
At the moment, we are using a temporary workaround for the following steps: Let me know if you need any further clarification or if you have any ideas on how to improve the data flow. |
@djee-ms Our use-case looks like this:
Currently, we are reading the processed frame from the texture and are sending it via a TCP connection to HoloLens. Our goal is to replace this connection by webRTC and in particular profit from hardware decoding/encoding support. |
@jahnotto thanks for the details. A few comments:
Otherwise it seems there is no major concern for the external video track feature. That should work with it as currently designed. @chrisse27 thanks for the update too. Can I confirm in your case what you mean by "process each frame"? Is that done on the CPU side, or via GPU using shaders? Because grabbing a frame from the camera (VRAM) to pull it down to CPU memory for processing and re-uploading immediately to VRAM for hardware encoding for example would be a performance issue. This is incidentally what currently happens for H.264 on UWP and what we want to fix to get CPU usage and thermals lower. If you stay in system memory though and use a software encoder (VP8, VP9) it won't matter. |
@jahnotto my application has a similar pipeline right now to render remotely on a PC. You might want to take a look at 3D Streaming Toolkit which aims to solve a similar problem. |
@djee-ms In our application, the processing is done via GPU using shaders. |
Step 1: I am worried too :) So far it seems fine, but I haven't done any real performance/latency testing because the way we encode frames now (frame-wise jpegs) introduce a very high latency anyway. I read through #83 earlier after you mentioned it in a reply on slack. It seems like the proposed solutions there (hacking the RTP header) requires that I already send a video stream from the hololens to the PC. In my case, I'm only sending camera/frustum settings + any interaction data like clipping planes etc. Step 6: Thanks, multiplexing seems to be a good solution to sending metadata. Will I be able to use a multiplexed codec through MR-WebRTC though? |
I had a look on it some time ago. I gave it up because it doesn't support the Unity editor, and it doesn't build for ARM. MR-WebRTC seemed to be more promising. |
I didn't try it to be honest, though it should be like any other codec and work out of the box. The issue is that no metadata API is exposed, so would require some work to surface something in MR-WebRTC, which might be troublesome according to that comment from #83:
Also, there is the (unconfirmed) absence of SDP codec negotiation as mentioned on #83. Would that work for your use case? Can you assume an encoding is supported on both sides? |
I have full control of the hardware and software on both sides. Hence it should be safe to assume that a specific encoding is supported on both sides. |
This change adds support for so-called "external video tracks", which are local video tracks backed by an external source from the user. Unlike the implicit source of a regular local video tracks, which captures video frame from a local video capture device (webcam), an external video track source dispatches to the WebRTC video engine some frames provided by the user. This frame source is external from the point of view of the WebRTC video engine, which doesn't know their origin. External video track sources allow the user to build local video tracks backed by a custom video source, be it a procedurally generated image, some rendered content, or even a frame from a video capture device not natively supported by the underlying WebRTC implementation. This change does not include any integration with Unity, although external video track sources are exposed in C# so can still be used via the C# library. Further integration will provide built-in Unity components for these. Issue: microsoft#35
Add some Unity integration of the external video tracks feature by way of a CustomVideoSource component allowing the user to inject some custom video feed in the WebRTC connection. As an example application, provide a SceneVideoSource component capturing the content rendered by a given Unity camera and streaming it as a video feed to the remote peer. The VideoChatDemo Unity scene is updated to add a scene capture view showing via a MediaPlayer component the scene content captured from the camera back-buffer. Bug: #35
Hey, How did you encode render texture. Can you please explain me how you encoded it to h.264 and also does it use gpu for encoding. Please this would be big help 🙏 |
can Support customize local Video source like renderTexture or some video player rendered texture?
also I want get and send rgb/D frame from kinect-dk
The text was updated successfully, but these errors were encountered: