AM62A7-Q1: v4l2h265enc fails with Failed to process frame on second encoder stream when using tiovxmemalloc to provide buffers

Part Number: AM62A7-Q1

Tool/software:

Hi  ,

My application uses a completely dynamic setup, where I create an initial pipeline for the camera going through the ISP and LDC, through multiple tees and ending in a fakesink after a valve element.

Before, I had to use output-io-mode=dmabuf on v4l2h265enc to get this to work correctly; this resulted in a framerate of about 20 fps.

Since then, I've played around with tiovxmemalloc to try and improve the framerate. If I use this in the initial pipeline, things don't work correctly (tiovxmemalloc complains it can't allocate memory). If I move the tiovxmemalloc to the dynamic pipeline(s), things work as expected as long as I only have one v4l2h26{4,5}enc element. The moment I have two, the second v4l2h26{4,5}enc element complains it can't process the frame.

The pipeline looks like this in that case:

v4l2src -> capsfilter -> tiovxisp -> tiovxldc -> capsfilter -> queue -> tee -> queue -> valve -> textoverlay -> tiovxmemalloc -> queue -> v4l2h265enc -> capsfilter -> rtph265pay -> udpsink (to a multicast address)
                                                                                                                \-> queue -> tiovxmultiscaler -> capsfilter -> tee (HD Video) -> queue -> valve -> textoverlay -> tiovxmemalloc -> queue -> v4l2h265enc -> capsfilter -> rtph265pay -> udpsink
                                                                                                                                                                                                               |-> queue -> tiovxmultiscaler -> ticolorconvert -> capsfilter -> motioncells -> queue -> valve
                                                                                                                                                                                                               \-> queue -> valve

My initial pipeline has a fakesink behind the first two valves; when I enable a stream, I close the valve and replace the fakesink with the elements above. Without the tiovxmemalloc, I have to use output-io-mode=dmabuf on v4l2h265enc to get it working at ~20fps. With the tiovxmemalloc, I can get one stream working at 30 fps when using H.26x encoding. I tried putting one tiovxmemalloc element after the tiovxldc, and this resulted in memory allocation failures when starting up the pipeline.

Any idea how to place the tiovxmemalloc to ensure this works correctly?

Thanks,

Bas Vermeulen