Decode memory problem

I am using xavier nx to access seven hevc video streams, 6 channels of 4k resolution, and 1 channel of 1080p resolution. I call the nv decoder of ffmpeg and find that the decoder takes up a lot of memory during the decoding process. My device With only 8g of memory, it can barely run, and it also uses the swap area. To this end, I conducted a test and verified that after the program is initialized, my program only occupies 1G of memory, and when the decoding starts, it increases 7G of memory. So I can be sure that it is the memory occupied by ffmpeg’s internal application during the decoding process. How can I reduce the memory usage? I need to reduce the memory by at least 1g. If it is feasible to change the decoding sdk, but this is my last choice, because it takes a lot of time.

We would suggest try jetson_multimedia_api sample:


This is low-level software stack for hardware video decoding. Please give it a try. If it runs fine for the use-case, we would suggest base on jetson_multimedia_api for development.

I prefer to modify the nvv4l2_dec.c source code of ffmpeg, but when I try to modify the value of MAX_BUFFERS lower than 28, there is a crash problem. Do you have any advice to offer? When MAX_BUFFERS=28 instead of 32, I can decode smoothly and reduce the memory usage by about 400MB, but I hope to reduce more.

Please check query_and_set_capture() in 00_video_decode sample. You will see the function call:

ret = dec->getMinimumCapturePlaneBuffers(min_dec_capture_buffers);

It returns required minimum buffer number. Please not to allocate buffer number less than the returned value, or it may not work properly.

I have checked the min_dec_capture_buffers value,min_dec_capture_buffers = 9. and I success to set MAX_BUFFERS = 12. why NvBufferTransform should be called in decode?10 src dma buffers and 12 dst dma buffers still occupy a large memory,

The decoded frame data is in block linear. Would need to convert to pitch linear for further processing.

Thanks for reply.Can I do resize and color convert by the NvBufferTransform way? Because I do these after I finish decoding.


Hardware converter supports it. There are multiple demonstrations in jetson_multimedia_api samples. You may search for it or refer to


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.