Online encoder reconfiguration

Hi.
How to make properly online encoder reconfiguration without closing handle?

Is there a minimal code example?

Hi,
Please share more detail about the usecase. Not sure what your request is.
We support gstreamer and tegra_multimedia_api. IF you run gstreamer, you may share the working pipeline of the usecase with x264enc. We can then check if hardware encoder nvv4l2h264enc can support the same.

Hi.
I need change output stream size for example. I write in C (using tegra multimedia api as a basis). I don’t use gstreamer

I do like this:

  • suspend encoding loop
  • flush both planes by queueing buffers with zero length (wait for a buffer of zero length in response)
  • send VIDIOC_STREAMOFF ctl to both planes
  • deallocate output and capture plane buffers (i use DMA buffers on oputput plane, MMAP on capture plane)
  • set new planes format with new size
  • allocate new buffers for planes
  • send VIDIOC_STREAMON ctl to both planes
  • resume encoding loop

It’s correctly?

But i see memory leak after 2 reconfiguration like this when the new size is taken first and then the old size again .

I read /sys/kernel/debug/nvmap/iovmm/clients file for check current memory allocations.

I use a similar algorithm when closing the encoder, when a last call is v4l2_close(fd) and there are no leaks.

Try to do this using tegra multimedia api, please.

Hi,
For information, please share your release version( $ head -1 /etc/nv_tegra_release ).

We have certain fix for NvVideoEncoder on r28.2.1:
https://elinux.org/Jetson_TX2/28.2.1_patches
[MMAPI]Cannot run NvVideoDecoder in loop/Memory leak in NvVideoEncoder
If you use this version, please replace the prebuilt lib and give it a try.

head -1 /etc/nv_tegra_release
# R32 (release), REVISION: 2.1, GCID: 16294929, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug 13 04:45:36 UTC 2019

Hi,
If width and height are changed, please delete NvVideoEncoder and re-initialize new one. The reference sample is 01_video_encode and this usecase is not included and not verified. Would suggest you run with ‘-s ’ and look at the sample to see how it works.