Gstreamer bitrate modification in TX2

Hey! I have a system streaming with webrtc to clients using the following pipelines:

Source :

 launch_string = "rtspsrc location="+ source_name +" ! queue ! rtph264depay ! video/x-h264, stream-format=byte-stream,framerate=25/1 ! h264parse ! queue ! nvv4l2decoder ! queue ! nvvidconv name=myconv !  video/x-raw(memory:NVMM), format=RGBA ! nvvidconv ! video/x-raw(memory:NVMM), format=NV12 ! queue ! nvv4l2vp8enc bitrate=100000 ! video/x-vp8 ! queue max-size-bytes=0 ! rtpvp8pay ! udpsink host=224.1.1.1 port=5000 sync=false  auto-multicast=true";

Webrtc:

 pipeline =   "udpsrc multicast-group=224.1.1.1 auto-multicast=true port=5000 ! queue max-size-bytes=0 ! application/x-rtp,media=video,clock-rate=90000,encoding-name=VP8,payload=96, framerate=25/1 ! webrtcbin name=sendrecv latency=0";

The program is working mostly ok but we’ve experienced some cuts in the client stream when using 4k video (the stream when caught after source is fluid, the quality loss is at clients) and we wanted to reduce bitrate to give clients some air and try to improve overall performance, but adding nvv4l2vp8enc bitrate=100000 doesn’t seem to lower the bitrate, clients still receive 4Mbps when watching the stream. I’ve checked all of the other elements options and none allow bitrate modification. How could I archive this properly?

thanks!

Hi,

You may want to explore other encoder parameters, such as vbv-size and quantization, take a look at this documentation:

Encoder Features with GStreamer-1.0

A useful tool for pipeline tuning is GstShark, it allows to check the bitrate in the encoder output:

GstShark Bitrate_tracer

Jennifer

Hi! Thanks for your help!

Do know if GstShark can be used with gstreamer code not just gst-launch pipelines? I’ve tried using it but it doesn’t seem to give any output at all in gstreamer 16.2

I have another question in case you can help me. I read that VP9 works better for 4k and should give a better quality with less Bitrate but changing my pipeline from h264-vp8 to h265-vp9 result in much worse performance overall and I can’t find the reason

Hi,

Yes, it can be used for other applications too, assuming the app initializes the GStreamer library with gst_init. The usage would be similar than with gst-launch:

GST_DEBUG=“GST_TRACER:7” GST_TRACERS=“bitrate” ./app

Hi,

Yes, with the same input and using vp9 I’d expect to get a similar quality than with vp8 but with less bitrate or better quality than with vp8 with a similar bitrate, depending on the encoder configuration. The TX2 capabilities for both hardware encoders are equal according to this documentation, perhaps there is a bottleneck somewhere in the pipeline that might be limiting the performance?

You may find this thread interesting.

Jennifer
https://www.ridgerun.com/

Hi! Thanks for your help!

I still cannot make GstShark work, I don’t know what the reason could be, could it be because my gstreamer isn’t installed in the default location? Is there a way to modify that? I tried with -prefix and --libdir when installing but it did nothing

Hi,

The problem could be that gst-shark is not being installed in the path where GStreamer is looking for the plugins. Try this:

GST_PLUGIN_PATH=/home/rrtx2/gst-shark/plugins/tracers/.libs gst-inspect-1.0 sharktracers

but replace /home/rrtx2/gst-shark/plugins/tracers/.libs by the absolute path to the directory where the libgstsharktracers.so and libgstshark.so are in your system. You could use the gst-shark build directory gst-shark/plugins/tracers/.libs for this test.

The expected result would be something like this:

Plugin Details:
Name                     sharktracers
Description              GstShark tracers
Filename                 /home/rrtx2/gst-shark/plugins/tracers/.libs/libgstsharktracers.so
Version                  0.6.1.1
License                  LGPL
Source module            gst-shark
Source release date      2020-07-29 20:13 (UTC)
Binary package           GstShark
Origin URL               https://github.com/RidgeRun/gst-shark

cpuusage (GstTracerFactory)
graphic (GstTracerFactory)
proctime (GstTracerFactory)
interlatency (GstTracerFactory)
scheduletime (GstTracerFactory)
framerate (GstTracerFactory)
queuelevel (GstTracerFactory)
bitrate (GstTracerFactory)
buffer (GstTracerFactory)

9 features:
+-- 9 tracers

If this works, then run your app like this:

GST_PLUGIN_PATH=/home/rrtx2/gst-shark/plugins/tracers/.libs GST_DEBUG=“GST_TRACER:7” GST_TRACERS=“bitrate” ./app

Jennifer
https://www.ridgerun.com

Thank you so much! I managed to make it work, however I ran into a few issues while trying to profile the pipeline. Since they seemed like very gst-shark specific issues I posted them here