When using libx264 encoding on Orin Nano, the CPU usage is 27%. How can I reduce the CPU usage?

  1. My system version is Orin Nano.
    uniubi@ubuntu:/usr/lib/aarch64-linux-gnu$ cat /etc/nv_tegra_release

    R36 (release), REVISION: 4.4, GCID: 41062509, BOARD: generic, EABI: aarch64, DATE: Mon Jun 16 16:07:13 UTC 2025

    KERNEL_VARIANT: oot

    TARGET_USERSPACE_LIB_DIR=nvidia
    TARGET_USERSPACE_LIB_DIR_PATH=usr/lib/aarch64-linux-gnu/nvidia
    uniubi@ubuntu:/usr/lib/aarch64-linux-gnu$

  2. I modified a sample to capture frames from USB and convert them to YUV format images.

  3. I started an encoding thread named H264EncThread, which uses libx264 and interfaces like avcodec_send_frame to encode YUV into an H.264 stream.

  4. Currently, I observe that the H264EncThread’s CPU usage is as high as 27%.
    This CPU usage far exceeds my expectations; I hope to achieve an H.264 encoding thread with CPU usage no higher than 5%.

  5. Is this high H.264 encoding CPU usage related to libx264.so.163? Are there other methods, such as leveraging CUDA or hardware-accelerated encoding,
    to reduce the encoding thread’s CPU usage? Are there any relevant low-CPU H.264 encoding samples I can refer to?

  6. Attached is the source code of my sample.
    29_usb_camera_sw_encode_h264h265.zip (1.9 MB)

Hi,
Because Orin Nano does not have hardware encoder, you would need to use the software encoder and the CPU usage is expected.

Got it, thanks!