H265 1080P 30FPS error on JetPack5.1.1 ORIN NX 16G

Problem Description

Hardware device: Apeax Orin NX

System version: 5.1.1

Module: Orin NX 16G

Procedure:

  1. Generate a YUV file (for reference only; any 1080p file will work)
# Generate file
nvidia@miivii-tegra:/usr/src/jetson_multimedia_api/samples/15_multivideo_encode$
sudo ffmpeg -f lavfi -i testsrc=size=1920x1080:rate=30:duration=10 -pix_fmt yuv420p -y ../07_video_convert/video420.yuv0

2.Enter the NVIDIA video encoding API and modify multivideo_encode_main.cpp

bash

cd /usr/src/jetson_multimedia_api/samples/15_multivideo_encode

Add code to record the encoding completion time in multivideo_encode_main.cpp.

The modified file is as follows:
multivideo_encode_main.txt (35.1 KB)

sudo make

3.Run 8-channel 1080p video encoding to check if it meets the specified parameter of 1080p 30FPS.

Run the following command:

nvidia@miivii-tegra:/usr/src/jetson_multimedia_api/samples/15_multivideo_encode$

sudo ./multivideo_encode num_files 8 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test1.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test2.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test3.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test4.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test5.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test6.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test7.h265 \

…/07_video_convert/video420.yuv0 1920 1080 H265 test8.h265 \

Abnormal Phenomenon

Under 8-channel 1080p30 H.265 encoding, the encoding delay becomes greater than the frame interval.

The output can be seen in the log

nvidia@miivii-tegra:/usr/src/jetson_multimedia_api/samples/15_multivideo_encode$ sudo ./multivideo_encode num_files 8 ../07_video_convert/video420.yuv0  1920 1080 H265 test1.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test2.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test3.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test4.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test5.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test6.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test7.h265 ../07_video_convert/video420.yuv0  1920 1080 H265 test8.h265 \
> 
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: H265 : Profile : 1 
NvVideo: H265 : Profile : 1 
NVMEDIA: Need to set EMC bandwidth : 846000 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
NvVideo: bBlitMode is set to TRUE 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: H265 : Profile : 1 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: H265 : Profile : 1 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
NvVideo: H265 : Profile : 1 
NVMEDIA: Need to set EMC bandwidth : 846000 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: bBlitMode is set to TRUE 
NvVideo: H265 : Profile : 1 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: H265 : Profile : 1 
Opening in BLOCKING MODE 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvMMLiteOpen : Block : BlockType = 8 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
892744264
842091865
NvVideo: bBlitMode is set to TRUE 
NvVideo: H265 : Profile : 1 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
通道 4 帧 6 编码间隔: 39ms
通道 6 帧 3 编码间隔: 46ms
通道 0 帧 22 编码间隔: 35ms
通道 3 帧 18 编码间隔: 39ms
通道 2 帧 10 编码间隔: 39ms
通道 4 帧 7 编码间隔: 45ms
通道 0 帧 23 编码间隔: 35ms
通道 6 帧 4 编码间隔: 59ms
通道 3 帧 19 编码间隔: 39ms
通道 2 帧 11 编码间隔: 43ms
通道 4 帧 8 编码间隔: 43ms
通道 6 帧 5 编码间隔: 44ms
通道 1 帧 25 编码间隔: 35ms
通道 3 帧 20 编码间隔: 37ms
通道 2 帧 12 编码间隔: 38ms
通道 4 帧 9 编码间隔: 42ms
通道 3 帧 21 编码间隔: 37ms
通道 2 帧 13 编码间隔: 35ms
通道 7 帧 5 编码间隔: 35ms
通道 2 帧 14 编码间隔: 35ms
通道 6 帧 8 编码间隔: 35ms
通道 7 帧 6 编码间隔: 35ms
通道 1 帧 30 编码间隔: 34ms
通道 7 帧 8 编码间隔: 34ms
通道 0 帧 30 编码间隔: 36ms
通道 3 帧 25 编码间隔: 35ms
通道 5 帧 21 编码间隔: 35ms
通道 4 帧 14 编码间隔: 35ms
通道 2 帧 17 编码间隔: 35ms
通道 6 帧 11 编码间隔: 35ms
通道 1 帧 31 编码间隔: 36ms
通道 7 帧 9 编码间隔: 36ms
通道 0 帧 31 编码间隔: 36ms
通道 3 帧 26 编码间隔: 36ms
通道 5 帧 22 编码间隔: 35ms
通道 4 帧 15 编码间隔: 36ms
通道 2 帧 18 编码间隔: 36ms
通道 6 帧 12 编码间隔: 36ms
通道 1 帧 32 编码间隔: 34ms
通道 7 帧 10 编码间隔: 34ms
通道 3 帧 30 编码间隔: 34ms
通道 5 帧 26 编码间隔: 34ms
通道 4 帧 19 编码间隔: 35ms
通道 2 帧 22 编码间隔: 35ms
通道 6 帧 16 编码间隔: 35ms
通道 1 帧 36 编码间隔: 34ms
通道 7 帧 14 编码间隔: 35ms
通道 0 帧 36 编码间隔: 34ms
通道 3 帧 31 编码间隔: 35ms
通道 5 帧 27 编码间隔: 35ms
通道 4 帧 20 编码间隔: 35ms
通道 2 帧 23 编码间隔: 35ms
通道 6 帧 17 编码间隔: 35ms
通道 1 帧 37 编码间隔: 34ms
通道 7 帧 15 编码间隔: 35ms
通道 0 帧 37 编码间隔: 34ms
通道 5 帧 30 编码间隔: 35ms
通道 4 帧 23 编码间隔: 34ms
通道 2 帧 26 编码间隔: 34ms
通道 6 帧 20 编码间隔: 35ms
通道 1 帧 40 编码间隔: 35ms
通道 7 帧 18 编码间隔: 35ms
通道 0 帧 40 编码间隔: 34ms
通道 3 帧 35 编码间隔: 35ms
通道 5 帧 31 编码间隔: 34ms
通道 4 帧 24 编码间隔: 34ms
通道 2 帧 27 编码间隔: 34ms
通道 6 帧 21 编码间隔: 34ms
通道 1 帧 41 编码间隔: 34ms
通道 7 帧 19 编码间隔: 35ms
通道 0 帧 41 编码间隔: 34ms
通道 3 帧 36 编码间隔: 35ms
通道 2 帧 30 编码间隔: 34ms
通道 6 帧 24 编码间隔: 35ms
通道 1 帧 44 编码间隔: 34ms
通道 7 帧 22 编码间隔: 35ms
通道 0 帧 44 编码间隔: 34ms
通道 3 帧 39 编码间隔: 34ms
通道 5 帧 35 编码间隔: 35ms
通道 4 帧 28 编码间隔: 35ms
通道 2 帧 31 编码间隔: 35ms
通道 6 帧 25 编码间隔: 35ms
通道 1 帧 45 编码间隔: 34ms
.................................
..................................

Could not read complete frame from input file
File read complete.
Could not read complete frame from input file
File read complete.
通道 3 帧 286 编码间隔: 34ms
通道 6 帧 272 编码间隔: 34ms
通道 4 帧 275 编码间隔: 34ms
通道 2 帧 278 编码间隔: 34ms
通道 5 帧 282 编码间隔: 34ms
通道 7 帧 270 编码间隔: 34ms
通道 3 帧 287 编码间隔: 35ms
通道 6 帧 273 编码间隔: 34ms
通道 4 帧 276 编码间隔: 34ms
通道 5 帧 283 编码间隔: 34ms
通道 7 帧 271 编码间隔: 34ms
Could not read complete frame from input file
File read complete.
通道 5 帧 286 编码间隔: 34ms
通道 7 帧 274 编码间隔: 34ms
通道 6 帧 277 编码间隔: 34ms
通道 4 帧 280 编码间隔: 34ms
通道 2 帧 283 编码间隔: 34ms
通道 5 帧 287 编码间隔: 35ms
通道 7 帧 275 编码间隔: 34ms
通道 6 帧 278 编码间隔: 34ms
通道 4 帧 281 编码间隔: 34ms
通道 2 帧 284 编码间隔: 34ms
Got 0 size buffer in capture 
通道 4 帧 282 编码间隔: 35ms
通道 2 帧 285 编码间隔: 35ms
Got 0 size buffer in capture 
Could not read complete frame from input file
File read complete.
Instance 1 executed successfully.
Instance 0 executed successfully.
Could not read complete frame from input file
File read complete.
Got 0 size buffer in capture 
Instance 3 executed successfully.
Could not read complete frame from input file
File read complete.
Got 0 size buffer in capture 
Could not read complete frame from input file
File read complete.
Instance 5 executed successfully.
Could not read complete frame from input file
File read complete.
Got 0 size buffer in capture 
Instance 2 executed successfully.
Got 0 size buffer in capture 
Got 0 size buffer in capture 
Instance 4 executed successfully.
Got 0 size buffer in capture 
Instance 6 executed successfully.
Instance 7 executed successfully.
App run was successful

Other Attempts:

  1. sudo jetson_clocks >>> Still encountered frames taking longer than 33ms.

  2. Reduced the bitrate from bitrate = 4 * 1024 * 1024 to 1 * 1024 * 1024 (4M to 1M) and 2M >>> The problem persisted.

Points of Inquiry

  1. Is calculating the encoding completion time frame by frame in this manner correct?

  2. How can the parameter of 8-channel 1080p 30fps H.265 video encoding be achieved?
    Additional note: Verifying the parameters does not necessarily require YUV files. I just want to confirm whether this device can achieve the processing speed for 8-channel H.265 encoding at 1080p 30FPS.

*** Please note that this reply is generated by LLM automatically ***

The question involves verifying the parameters of 8-channel 1080p 30FPS H265 video encoding on a Jetson Orin NX device. The user has modified the multivideoencode sample code to record the encoding completion time and is experiencing issues with the encoding delay being greater than the frame interval.

To address this question, we need to consider the capabilities of the Jetson Orin NX device and the parameters of the video encoding.

Device Capabilities:

The Jetson Orin NX device is a powerful AI computer that features an Ampere GPU, Arm Cortex-A78AE CPU, and up to 16GB of LPDDR5 memory. It supports various multimedia features, including video encoding and decoding.

Video Encoding Parameters:

The user is trying to achieve 8-channel 1080p 30FPS H265 video encoding. This means that the device needs to encode 8 simultaneous video streams at a resolution of 1920x1080, a frame rate of 30 FPS, and using the H265 codec.

Encoding Completion Time:

The user is calculating the encoding completion time frame by frame, which may not be the most accurate way to measure the performance of the device. A better approach would be to measure the overall encoding time for a given number of frames or a specific duration.

Bitrate and Encoding Delay:

The user has reduced the bitrate from 4M to 1M and 2M, but the problem persists. This suggests that the issue is not solely related to the bitrate, but rather the overall encoding performance of the device.

Achieving the Desired Parameters:

To achieve the desired parameters of 8-channel 1080p 30FPS H265 video encoding, the user may need to optimize the encoding settings, such as adjusting the bitrate, GOP size, and number of reference frames. Additionally, the user may need to consider using a more efficient encoding algorithm or a different codec.

Comparison with Other Devices:

The Jetson Orin NX device is a powerful AI computer, but its performance may vary compared to other devices in the Jetson family. For example, the Jetson AGX Orin device has a more powerful GPU and may be better suited for demanding video encoding tasks.

Conclusion:

In conclusion, achieving the desired parameters of 8-channel 1080p 30FPS H265 video encoding on a Jetson Orin NX device may require optimizing the encoding settings and considering the device’s capabilities and limitations. The user may need to experiment with different encoding settings and algorithms to achieve the desired performance. Additionally, comparing the performance of the Jetson Orin NX device with other devices in the Jetson family may provide valuable insights into its capabilities and limitations.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hi,
Please call the function in 15 sample:
Correct Frame Rate to Use with NvVideoEncoder::setFrameRate - #5 by DaneLLL

To fix NVENC engine at maximum clock. You can run $ sudo tegrastats to ensure NVENC is fixed at maximum frequency.

Hi

I try setMaxPerfMode(1); but error ,I want to know if my usage of setMaxPerfMode(1); is correct.

my code:
/* Create NvVideoEncoder object for blocking or non-blocking I/O mode. */
if (ctx.blocking_mode)

{ cout << “Creating Encoder in blocking mode\n”; ctx.enc = NvVideoEncoder::createVideoEncoder (“enc0”); }

else

{ cout << “Creating Encoder in non-blocking mode\n”; ctx.enc = NvVideoEncoder::createVideoEncoder (“enc0”, O_NONBLOCK); }

TEST_ERROR (!ctx.enc, "Could not create encoder", cleanup);

// ========== 正确的位置和调用方式 ==========
cout << “Setting encoder to max performance mode…” << endl;
ret = ctx.enc->setMaxPerfMode(1); // 通过对象调用
if (ret == 0)
{ cout << “Max performance mode enabled successfully” << endl; }

else
{ cerr << "Warning: Failed to set max performance mode (code: " << ret << “)” << endl; // 继续执行,不退出 }

my log:

NVENC 793 VIC_FREQ 69%

error log:

Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Creating Encoder in blocking mode
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvVideo: H265 : Profile : 1
NVMEDIA: Need to set EMC bandwidth : 846000
NvVideo: bBlitMode is set to TRUE
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NvVideo: H265 : Profile : 1
NvVideo: H265 : Profile : 1
NVMEDIA: Need to set EMC bandwidth : 846000
NVMEDIA: Need to set EMC bandwidth : 846000
NvVideo: bBlitMode is set to TRUE
NvVideo: bBlitMode is set to TRUE
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvVideo: H265 : Profile : 1
NVMEDIA: Need to set EMC bandwidth : 846000
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NvVideo: H265 : Profile : 1
NvVideo: bBlitMode is set to TRUE
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NVMEDIA: Need to set EMC bandwidth : 846000
通道 3 帧 3 编码间隔: 64ms
NvVideo: H265 : Profile : 1
NvVideo: bBlitMode is set to TRUE
NVMEDIA: Need to set EMC bandwidth : 846000
通道 1 帧 4 编码间隔: 61ms
NvVideo: bBlitMode is set to TRUE
通道 3 帧 4 编码间隔: 56ms
通道 1 帧 5 编码间隔: 69ms
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NvVideo: H265 : Profile : 1
NVMEDIA: Need to set EMC bandwidth : 846000
NvVideo: bBlitMode is set to TRUE
通道 1 帧 6 编码间隔: 37ms
通道 3 帧 6 编码间隔: 35ms
通道 1 帧 7 编码间隔: 34ms
Opening in BLOCKING MODE
Setting encoder to max performance mode…
[ERROR] (NvVideoEncoder.cpp:357) Should be called after setting plane formats
Warning: Failed to set max performance mode (code: -1)
NvMMLiteOpen : Block : BlockType = 8
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NvVideo: H265 : Profile : 1
通道 7 帧 4 编码间隔: 38ms
NVMEDIA: Need to set EMC bandwidth : 846000
NvVideo: bBlitMode is set to TRUE
通道 4 帧 3 编码间隔: 57ms
通道 4 帧 4 编码间隔: 61ms
通道 3 帧 13 编码间隔: 34ms
通道 7 帧 9 编码间隔: 34ms
通道 0 帧 29 编码间隔: 34ms
通道 4 帧 5 编码间隔: 35ms
通道 5 帧 9 编码间隔: 34ms
通道 1 帧 15 编码间隔: 34ms
通道 6 帧 10 编码间隔: 34ms
通道 0 帧 30 编码间隔: 35ms
通道 4 帧 6 编码间隔: 34ms
通道 5 帧 10 编码间隔: 34ms
通道 1 帧 16 编码间隔: 34ms
通道 6 帧 11 编码间隔: 35ms
通道 2 帧 3 编码间隔: 35ms
通道 3 帧 15 编码间隔: 35ms
通道 7 帧 11 编码间隔: 34ms
通道 0 帧 31 编码间隔: 34ms
通道 4 帧 7 编码间隔: 34ms
通道 5 帧 11 编码间隔: 35ms
通道 1 帧 17 编码间隔: 35ms
通道 6 帧 12 编码间隔: 34ms
通道 2 帧 4 编码间隔: 35ms
通道 3 帧 16 编码间隔: 35ms
通道 7 帧 12 编码间隔: 34ms
通道 1 帧 30 编码间隔: 34ms

Hi,
In 15 sample, the encoder parameters are configured in encode_proc(). You can call setMaxPerfMode() along with the parameters. And check if it takes effect by checking NVENC frequency in $ sudo tegrastats

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