H265 Encoder hangs when using slice level encode option

Hi,

I’m testing H265 slice level encoding. When I ran video_encode using slice level encoding,
encoding process hangs.

Environment

  • Connect Tech Rudi AGX Xavier
  • JetPack 4.6.2

Encoding commands.

$ video_encode input.yuv 1920 1080 H265 /dev/null -br 3000000 -pbr 4500000 -rc vbr \
               -p main -l main4.1 -idri $((1 << 31)) -ifi $((1 << 31)) \
               -fps 25 1 -mem_type_oplane 1 -hpt 1 -s 65535 -slen 1024 -slt 1 --sle \
               --report-metadata

Input file is rush hour from derf’s collection. GDB info thread commands shows following.

(gdb) info thread
  Id   Target Id         Frame
* 1    Thread 0x7f8eb26430 (LWP 11195) "EncOutPlane" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>,
    expected=0, futex_word=0x5574ea8aa8) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  2    Thread 0x7f8dbf41d0 (LWP 11196) "drm_vbl" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>, expected=0,
    futex_word=0x5574e0f988) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  3    Thread 0x7f8d3f31d0 (LWP 11197) "drm_pflip" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>, expected=0,
    futex_word=0x5574e0f958) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  4    Thread 0x7f8cbf21d0 (LWP 11198) "drm_vbl" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>, expected=0,
    futex_word=0x5574e0fa38) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  5    Thread 0x7f8c3f11d0 (LWP 11199) "drm_pflip" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>, expected=0,
    futex_word=0x5574e0fa08) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  6    Thread 0x7f6b3fe1d0 (LWP 11209) "V4L2_EncThread" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>,
    expected=0, futex_word=0x7f5c000f18) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  7    Thread 0x7f6bbff1d0 (LWP 11210) "EncCapPlane" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>,
    expected=0, futex_word=0x7f5c03e3dc) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  8    Thread 0x7f6927c1d0 (LWP 11211) "NVMVidEncInputT" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>,
    expected=0, futex_word=0x5574e6234c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
  9    Thread 0x7f69a7d1d0 (LWP 11212) "V4L2_EncThread" 0x0000007f8eac62a4 in futex_wait_cancelable (private=<optimized out>,
    expected=0, futex_word=0x5574eeccc8) at ../sysdeps/unix/sysv/linux/futex-internal.h:88

regards.

Update minimal commands.

$ video_encode input.yuv 1920 1080 H265 /dev/null -br 3000000 -rc vbr -fps 25 1 \
               -hpt 1 -s 65535 --report-metadata

It seems that VBR option and hardware preset (ultrafast or fast) affect hang situation.

Hi,
Looks like it is not related to slice level encoding. Does it work if you save to a real file instead of setting to /dev/null?

Hi,

Does it work if you save to a real file instead of setting to /dev/null?

No. I tried to output to a real file, but video_encode hanged again. This is output file.
output.265 (1.4 MB)

I’m running stress test without slice level encoding option.
It still work for now.

Hi,
So it is not an issue happening every time. It happens when running a loop test. Is this correct?

Hi,

It happens when running a loop test. Is this correct?

It seems yes. Same issue has occurred using bash shell loop.

$ OPT="input.yuv 1920 1080 H265 /dev/null -rc vbr -hpt 1 -slt 1 -sle 256 --sle --report-metadata" # options without "-s option"
$ while :; do ./video_encode $OPT; done

Hi,
Please apply this and give it a try:
Memory Leak (Alloc/free mismatch) in Tegra multimedia API (encoder) - #6 by DaneLLL

So that libv4l2_nvargus.so will not be loaded. Please try and see if this helps.

Hi,

It had no affect to this issue. Same issue has occurred after renaming libv4l2_nvargus.so

Hi,
It seems like it happens in VBR mode + slice level encode. Do you observe the issue in CBR mode + slice level encode?

Hi,

Do you observe the issue in CBR mode + slice level encode?

I think so too. I couldn’t observe it using CBR mode + slice level encode.

It seems like it happens in VBR mode + slice level encode.

I think hardware preset is also affect this issue. If hardware preset is medium or slow,
I couldn’t confirm issue. but when preset is disable, ultrafast or fast, I had confirmed issue.

Hi,
We have checked this and the issue looks specific to Jetpack 4.6.2 + H265 encoding. It works fine when running Jetpack 4.6.2 + H264 and Jetpack 5.0.2 + H265.
We are debugging further on Jetpack 4.6.2 + H265 encoding.

Hi,
On Xavier/Jetpack 4.6.2, please enable –max-perf and give it a try.

Hi,

I got same result with when without --max-perf option.
Command is following.

$ OPT="input.yuv 1920 1080 H265 /dev/null -rc vbr -hpt 1 -slt 1 -slen 128 --sle --max-perf --report-metadata"
$ while :; do ./video_encode $OPT; done

When slice size is 256, it seems work.

Hi,
Is it fine to set to -sle 256 in your use-case?

Hi,
Sorry for late response.
We want use slice level encode, due to latency consideration. but specific slice size
has not yet been determined.

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