UnityRenderStreaming icon indicating copy to clipboard operation
UnityRenderStreaming copied to clipboard

Poor Video Quality (using Nvidia T4)

Open h-rlpl opened this issue 4 years ago • 17 comments

I'm hosting the render streaming server at Google Cloud Instance (8vCpu & 8GB ram) having Nvidia T4 as its GPU. When accessed the ip to view render streaming it appears mosaic/pixelated . It appears to be on poor quality. But sometimes when stayed still without making any movement the video quality will improvise and sometimes not. It appears to be dynamically the quality is being adjusted to deliver the frames.

-I've tried switching resolutions on render camera in unity to 720p & 1080 but the result appear to be same -I've checked the resource usage on GCE. Only 30% of cpu, ram and GPU were used to stream the videos. So there is still lot of space to utilize to render high quality streams but it isnt doing

  • I've checked the Bandwidth on my GCE. Its 1Gbps

-How can I improvise the render streaming video quality ?| -Is there a way to set the video codec formats to be delivered in Unity Webrtc ?

Attached the screenshots of the render video streams being received.

ss1 ss2 ss3

h-rlpl avatar Mar 11 '21 06:03 h-rlpl

How about ChangeVideoParameters method? https://docs.unity3d.com/Packages/[email protected]/api/Unity.RenderStreaming.VideoStreamBase.html

You can use webrtc-internal on Google Chrome for checking the bandwidth.

karasusan avatar Mar 11 '21 06:03 karasusan

How about ChangeVideoParameters method? https://docs.unity3d.com/Packages/[email protected]/api/Unity.RenderStreaming.VideoStreamBase.html

You can use webrtc-internal on Google Chrome for checking the bandwidth.

I cant edit the CameraStreamer.cs. RenderStreaming.cs or Broadcast.cs scripts as they are part of package (My changes are being reverted). Can I get a sample script from you that which can call the "ChangeVideoParameters" function you specified ?

h-rlpl avatar Mar 11 '21 07:03 h-rlpl

I guess that this is the same issue. Could you try the VP8 codec? https://github.com/Unity-Technologies/com.unity.webrtc/issues/205

karasusan avatar Mar 15 '21 02:03 karasusan

Can we use vp8 with hardware encoder ? Because, I want to fully use the GPU & reduce load on CPU

I guess that this is the same issue. Could you try the VP8 codec? Unity-Technologies/com.unity.webrtc#205

h-rlpl avatar Mar 15 '21 04:03 h-rlpl

@h-rlpl

Can we use vp8 with hardware encoder ? Because, I want to fully use the GPU & reduce load on CPU

Unfortunately, no it can not.

karasusan avatar Mar 16 '21 02:03 karasusan

Alright, Will be looking forward for HW Encoding feature :). I hope that resolves this issue Thank you

h-rlpl avatar Mar 16 '21 05:03 h-rlpl

2.3.0 and lower allowed you to change the bandwidth. I hope they add this feature back into 3.0 as it has a more reliable web connection (in older versions you'd sometimes have to refresh the sample webpage in order to see the stream).

ZeoWorks avatar Mar 21 '21 23:03 ZeoWorks

ChangeVideoParameters

FYI, I made a local copy of the unity render streaming plugin to edit the source in 3.0.1, and was able to call ChangeVideoParameters on the video streaming object after the on connect call. Significant bandwith improvements by increasing the max bitrate. I think we're still limited by h.264 as far as crispness goes. Most of the buggy artifacts were gone, and busy scenes look really decent, but a smooth gradient in a skybox will show bands and i don't think theres really a way around that right now.

LucasMoskun avatar Apr 04 '21 06:04 LucasMoskun

Related issue https://github.com/Unity-Technologies/UnityRenderStreaming/issues/453

karasusan avatar Apr 26 '21 03:04 karasusan

@LucasMoskun Can you give some insight as to where exactly you're calling ChangeVideoParameters? I'm having trouble pinpointing where exactly I should call it.

snkedive avatar May 05 '21 09:05 snkedive

@LucasMoskun Can you give some insight as to where exactly you're calling ChangeVideoParameters? I'm having trouble pinpointing where exactly I should call it.

I went to look back and it looks like I accidently bombed my local repo without pushing the final commit :-/

I'm taking a look to see now, the most important thing is creating a local copy of the plugin so changes don't get overwritten.

Try creating the parameters you want, and passing them into a ChangeVideoParameters call in the CreateTrack function of CameraStreamer.cs. If that doesn't work look at OnFoundConnection function in SingleConnection.cs where the track is returned. You should be able to tell if it's a video track and cast it to VideoStreamBase and make the ChangeVideoParameters call on that.

If I remember correctly, until the connection is made, the parameters that are retrieved from the sender.GetParameters() function call will be empty, so it will skip over the setting portion. I think this was the big gotcha

public void ChangeVideoParameters(string connectionId, ulong? bitrate, uint? framerate) { if (!Senders.TryGetValue(connectionId, out var sender)) return; RTCRtpSendParameters parameters = sender.GetParameters(); foreach (var encoding in parameters.encodings) ....

Please let me know if that helps (Seriously :-) I may have to come back and use this again... kicking myself for losing the changes.)

LucasMoskun avatar May 05 '21 14:05 LucasMoskun

My memory is that these changes did nothing at all in 2.x so I think this is a red herring. You probably haven't actually changed anything.

doctorpangloss avatar May 21 '21 17:05 doctorpangloss

My memory is that these changes did nothing at all in 2.x so I think this is a red herring. You probably haven't actually changed anything.

I was using version 3.0.1. It worked. I recorded a bitrate increase from 1.3 Mbps to over 7.5 Mbps. Obvious increase in visual fidelity comparable to h.264 HVENC NDI streaming. There were definitely some gotchas and had to create a local copy of the plugin to modify the source, but at the end of the day that was the function that made it happen.

LucasMoskun avatar May 21 '21 17:05 LucasMoskun

@LucasMoskun Why do you need to edit the codebase in order to call the ChangeVideoParameters function? It's public. I'm trying to get it to work, the only thing I'm missing is, how do I get the connectionId that I need to pass?

znebby avatar Jun 04 '21 16:06 znebby

If someone is still trying to get ChangeVideoParameters to work in the newest version have a look at my answer in #453 if it works for you

pilzinho avatar Jul 22 '21 12:07 pilzinho

memo: URS-330

karasusan avatar Nov 09 '21 02:11 karasusan

We are working on these issue to fix it now. https://github.com/Unity-Technologies/com.unity.webrtc/issues/205 https://github.com/Unity-Technologies/com.unity.webrtc/issues/180

karasusan avatar Feb 08 '22 03:02 karasusan

Recently I have been working on Unity render streaming with oculus quest 2, its working and running up but the video render quality is not that good, I have been trying to modify all the version of the WebRTC package and tried with the hardware encoder (H.264) and software encoder (VP8), software encoder is better but not the best. Can anyone have more options for optimization of video rendering, Thanks in advance.

ShubhDev25 avatar May 10 '23 03:05 ShubhDev25