Skip to content

Key frames management while capturing WebRTC in browser

Sometimes, browsers can send key frames (K-frames or I-frames) very unevenly that lead to freezes while playing the stream. There is the following parameter to make a browser send key frames with a specified frequency

periodic_fir_request=true

In this case WCS periodically send PLI requests making the browser to send key frames. The frequency can be set in milliseconds with the following parameter

periodic_fir_request_interval=5000

By default, PLI requests are send every 5 seconds.

To prevent excessive PLI requesting, the parameter is added since build 5.2.561 to set minimal interval allowed between two PLI requests

rtcp_pli_request_interval=1000

By default, the minimal interval is 1 second. To get key frames most stable it is recommended to set this parameter equal to periodic_fir_request, for example

periodic_fir_request=true
periodic_fir_request_interval=5000
rtcp_pli_request_interval=5000

Chromium based browsers key frames sending issues

In certain Chromium engine builds and in browsers based on them, Chrome 80 for example, key frames are sent with a constant frequency depending on stream publishing resolution when hardware acceleration is enabled:

  • below 720p - 2 seconds
  • 720p and higher - 1 second

When FullHD and 4K streams are published, key frame size is big enough to reduce channel bandwidth with a large number of them. That leads to freezes in stream published. In this case hardware acceleration should be disabled in browser settings

and key frames request frequency should be set manually as described above. For example, the frequency recommended to 4K streaming is at least 3-5 seconds.