Blocking when release encoder

Hi,

We use the encoder in tegra_multimedia_api,when release the encoder, the encoder maybe blocking.

We modify 01_video_encode to reproduce this issue. Just let the it keep looping.

In video_encode_main.cpp.

int
main(int argc, char *argv)
{
context_t ctx;
int ret = 0;
int error = 0;
bool eos = false;
unsigned int input_frames_queued_count = 0;

run_again:
eos = false;
ret = 0;
input_frames_queued_count = 0;



if (error)
{
cout << “App run failed” << endl;
}
else
{
cout << “App run was successful frame cnt:” << input_frames_queued_count << endl;
}

goto run_again;
return -error;
}

And run

./video_encode /run/shm/3d_1920x1080_60_6000K_360.yuv 640 360 H264 out.264 -p high -rc vbr -hpt 4 -nbf 2 --copy-timestamp 0

When it is blocking, we see it block at release encoder.

Failed to query video capabilities: Inappropriate ioctl for device
NvMMLiteOpen : Block : BlockType = 4
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
[ERROR] (NvV4l2ElementPlane.cpp:496) Output Plane:STREAMON successful
[ERROR] (NvV4l2ElementPlane.cpp:496) Capture Plane:STREAMON successful
===== MSENC blits (mode: 1) into tiled surfaces =====
Could not read complete frame from input file
File read complete.

Thanks!

Hi,
Are you on r28.2.1? Please share a patch on 01_video_encode so that we can reproduce the issue.

Hi, DaneLLL

Thank you for your reply.

We work at R28.1.0, and the reproduce method on top of this topic.

The yuv file is here, [url]http://120.77.3.207/3d_1920x1080_60_6000K_360.yuv[/url]

Thanks!

Hi zcs,
‘–copy-timestamp 0’ is not in default r28.1 release. Can you try clean r28.1?

Hi, DaneLLL

I had tested it in clean r28.1, it still blocks.

Hi zcs,
Does the issue happen if you run the command without any options?

./video_encode /run/shm/3d_1920x1080_60_6000K_360.yuv 640 360 H264 out.264

Hi, DaneLLL

I had tested it without any options, it still blocks.

Hi,
Please try attachment. We don’t reproduce the issue you reported, but include a fix in attached libtegrav4l2.so. Hope it helps.

Also we suggest you migrate to latest release.
r28_1_libtegrav4l2.zip (60.8 KB)

Hi, DaneLLL

I had tested the attachment, but it still blocks.

Please open 8 sessions by ssh and run the command at the same time. that is very easy to reproduce this issue.

Thanks!

Hi zcs,
Please try r28.2.1.

Multi-session encoding is not general case we have verified/tested in BSP release. It is more like customized usecase and we suggest you contact salesperson to get direct support.

Hi, DaneLLL

I had tested on r28.2.1, but I encounter the memory leak.

[ 6681.805725] Out of memory: Kill process 3882 (video_encode) score 20 or sacrifice child
[ 6681.813759] Killed process 3882 (video_encode) total-vm:2119080kB, anon-rss:1688kB, file-rss:155988kB

Thanks!

Please try
https://elinux.org/Jetson_TX2/28.2.1_patches
[MMAPI]Cannot run NvVideoDecoder in loop/Memory leak in NvVideoEncoder

Hi, DaneLLL

Thank you for your reply.

I see the patch is for TX1, is suitable for TX2?

Multimedia

[MMAPI]Cannot run NvVideoDecoder in loop/Memory leak in NvVideoEncoder

patch link
https://devtalk.nvidia.com/default/topic/1043548/jetson-tx1/-mmapi-please-merge-two-libtegrav4l2-so-that-modify-different-issues/post/5294104/#5294104

Yes, it is good for both TX1 and TX2.

Hi, DaneLLL

Thank you for your patch.

It seems to have fixed the memory leaks issue. I will test the blocking issue for a long time on r28.2.1.

In addition, I find the deocder also have the blocking issue, I create a new topic to report it.

[url]https://devtalk.nvidia.com/default/topic/1045455/jetson-tx2/blocking-issue-with-decoder/[/url]

Thank you for the help.