UnityRenderStreaming icon indicating copy to clipboard operation
UnityRenderStreaming copied to clipboard

[BUG]: SendOnly Unity to RecvOnly browser makes Hardware Encoder fall back to VP8

Open yvanzine opened this issue 3 years ago • 9 comments

Package version

Others

Environment

* OS: Ubuntu 20.04
* Unity version: 2022.1.3f1
* Graphics API: Vulkan
* Browser: Chrome
* Using DEVELOP branch for both webrtc and UnityRenderStreaming packages (feat/stability-project-develop)

Steps To Reproduce

There is motivation to use Sendonly on Unity peer and Recvonly on web browser because bitrate may be affected by upload speed of user and the fact that the bandwidth is asymmetric, download speed is great and upload speed is poor.

Sendonly was removed recently from the AddSenderTrack: public RTCRtpTransceiver AddSenderTrack(string connectionId, MediaStreamTrack track) { var peer = _mapConnectionIdAndPeer[connectionId]; RTCRtpSender sender = peer.peer.AddTrack(track); var transceiver = peer.peer.GetTransceivers().First(t => t.Sender == sender); // note:: This line is needed to stream video to other peers with hardware codec. // The exchanging SDP is failed if remove the line because the hardware decoder currently is not supported. // Please remove the line after supporting the hardware decoder. ~~transceiver.Direction = RTCRtpTransceiverDirection.SendOnly;~~ return transceiver; }

When I add the SendOnly back into the AddSenderTrack, H264 Hardware encoder is not offered to the web browser client and VP8 is instead provided.

Without this SendOnly line, I still see the SDP answer from browser come back with a=recvonly and I believe the video stream (NVENC H264 in Unity and ffmpeg on client ) is in fact sendrecv(unity)-recvonly(browser) but I would like to prove it. When I degrade upload bandwidth at the browser, the connection remains good.

Please confirm if this is the intended behavior of the change and close the ticket, if the connection is in fact sendonly-recvonly for video stream as intended.

Current Behavior

No response

Expected Behavior

No response

Anything else?

No response

yvanzine avatar Jul 06 '22 22:07 yvanzine

OK, I will check the issue. Thanks.

karasusan avatar Jul 07 '22 01:07 karasusan

Can you open OBS and confirm that NVENC is an option for recording? Sometimes on Linux nvenc doesn't work right out of the box and needs specific nvidia drivers.

ZeoWorks avatar Jul 11 '22 14:07 ZeoWorks

NVENC is a valid option, as I get H264 hardware encoding when sendrecv profile is used. I never use OSB for debugging webrtc or unity webrtc. Is it useful?

yvanzine avatar Jul 11 '22 15:07 yvanzine

@ZeoWorks Oh, could you tell me the detail of specific nvidia drivers?

karasusan avatar Jul 12 '22 01:07 karasusan

When you have a fresh install of Linux with a nvidia GPU, they will use open source drivers (xserver), this does not have nvenc support built in. You need to manually install nvidia drivers such as 470, 510 or 515. Hope this helps.

ZeoWorks avatar Jul 12 '22 10:07 ZeoWorks

@ZeoWorks Definitely. To use NvCodec, we need to install the proprietary driver provided by NVIDIA.

karasusan avatar Jul 13 '22 01:07 karasusan

memo: URS-469

karasusan avatar Jul 13 '22 06:07 karasusan

@yvanzine

  1. In the current develop, if you specify the H264 codec in the Receiver on the Browser side, Fallback does not occur and H264 is used. Try specifying the Sender codec in UnitySide once the #726 has been merged into Develop branch.
  2. Changing to SendRecv is the default behavior of PeerConnection.AddTrack, so as intended. On the Broadcast sample in current develop branch, received Answer with RecvOnly on the Browser side, RTPRtcTransceiver.CurrentDirection of the Sender on the Unity side will be SendOnly.
  3. Bitrate can only be changed on the Sender side, can't on the Receiver side. You can change Bitrate by using SetBitrateMethod.(We are currently creating a Bitrate change sample PR https://github.com/Unity-Technologies/UnityRenderStreaming/pull/730)

kannan-xiao4 avatar Aug 08 '22 03:08 kannan-xiao4

@yvanzine Do you have any updates ? We close the issue if nothing.

kannan-xiao4 avatar Aug 22 '22 02:08 kannan-xiao4