Problem with C++ gstreamer pipeline

Hi,
Please refer to the following samples:
What is maximum video encoding resolution in pixels? - #11 by DaneLLL
GStreamer freeze when using qtmux and NVIDIA-accelerated h264/h265 encoding - #7 by DaneLLL

There are also samples in DeepStream SDK:

/opt/nvidia/deepstream/deepstream-5.1/sources/apps/sample_apps