Skip to content

screencastService: Improve the gstreamer pipeline for recording

The current gstreamer pipeline performs quite bad on slower machines and is dropping lots of frames, improve the pipeline by changing a few things:

  • Use threads for videoconvert and improve speed of videoconvert by disabling some unneeded things
  • Add a queue before the encoding step, this allows the encoder to work at its own pace and will lead to a lot more stability
  • Remove the fixed quantizer and only set a max quantizer, this helps quite a bit with performance
  • Change the deadline parameter of vp8enc to 1: This makes the encoder go into real time mode, which will make it a lot faster
  • Set cpu-used to 16, the maximum possible value.
  • Set static-threshold to 1000, static-threshold is the motion detection threshold, and while a value of 100 is recommended for screencasting in the gstreamer documentation (see [1]), using 1000 appears to perform a lot better and still outputs fairly good quality
  • Set a larger buffer size than the default size, this seems to get a bit more stability during high load scenarios

All in all, those changes make the pipeline drop no more frames when recording at 30 FPS and 2K screen resolution. That was tested on a fairly recent mobile core-i5 processor.

Also, because we now have two %T replacement strings for the number of threads, we need to switch to replaceAll(). For that to work, we have to put the %T matching expression into quotes.

Edited by Jonas Dreßler

Merge request reports