Setting V4L2 Encoder Bitrate

I’m setting V4L2_CID_MPEG_VIDEO_BITRATE, however it seems to only take effect if I set it at initialization time. Since nvv4l2h264enc does this correctly, is that element open source? I can look at how it’s properly implemented and see what I’m doing wrong.

Alternatively, is there a good way to output some debug information?

changing bitrate in runtime is demonstrated in


Please take a look and give it a try.

Thanks for the pointer. Is it possible to intercept the commands sent to /dev/nvhost-msenc and log them? I looked at the example and am trying to figure out why the example works but my code doesn’t. Thanks!

Is there a way to query the encoder’s state? Like v4l2-ioctl -d /dev/video0 --all

We have defined NvVideoEncoder class for video encoding. Would be better you follow the samples.

And do you use gstreamer? If yes, you can refer to source code of gst-v4l2.

I am following the samples however for some reason I am not able to set the bitrate once encoding has started. I’d like to figure out why the later commands are being ignored, I’m not sure if there’s a difference in configuration.

Specifically, this function call succeeds but doesn’t have any effect after encoding has started: Jetson Linux API Reference: NvVideoEncoder Class Reference | NVIDIA Docs

We still see the original bitrate being output.

I am not using gstreamer, but I’d like to match the ioctl calls from gstreamer to our code if possible.

Ok, the answer to this was that there is a secret environment variable LIBV4L2_LOG_FILENAME that can be set. LIBV4L2_LOG_FILENAME=~/v4l2.log gst-launch-1.0 videotestsrc ! nvvidconv ! nvv4l2h264enc ! fakesink produces the sequence of ioctl requests that I’m looking for.