I would like to control framerate and bitrate dynamically, depending on webrtc network conditions, I would like to set either of them at a given time to create a better user experience. At this point I think I exhausted all options with the H264 NVidia encoder codec 6.2 upgrade. I have read on the forum that some people are successful with changing the bitrate, min or max. I was also able to control the framerate by modifying the encoding parameters in the webrtc native code. I am mostly interested in framerate control and bitrate control is still important, but less so.
There is a function that allows me to update framerate:
WebBrowserInputSample has a function I am using, but it only works when the stream has just been created:
private IEnumerator HandleStreamStarted(CameraStreamer cameraStreamer, string connectionId)
{
// The parameters are not available right away so wait for them
yield return new WaitForEndOfFrame();
Debug.Log($"WebRTC stream connected: {cameraStreamer.name} has {cameraStreamer.Senders.Count} active connections, maxBitrate {maxBitrate}, encodedFps {encodedFps}");
cameraStreamer.ChangeVideoParameters(connectionId, (ulong)(maxBitrate * 1024 * 1024), encodedFps);
yield return null;
}
Calling a modified ChangeVideoParameters at a later arbitrary point of time changes the encoding parameters of a stream, but unfortunately does nothing to the stream properties in chrome://webrtc-internals.
Does anyone know why ChangeVideoParameters only makes a difference at stream start time?
No this is a different issue. This is specific to ChangeVideoParameters. If I set max framerate at the time of stream creation, I see the correct max framerate. When I call ChangeVideoParameters later, when the stream has been running and displaying, the max framerate does not change and I get some artifacts instead.
I am sorry I think I must have forgotten how the original problem occured. I now have full memory of how ChangeVideoParameters operates.
Basically I want to control bitrate and framerate. None of them work via ChangeVideoParameters. ChangeVideoParameters does not do anything unfortunately.
I am able to set max framerate only through the Unity Engine itself which works well for me, for now: