How to set CQP encode mode in Jetson AGX Orin

How to set Constant QP encode mode in Jetson AGX Orin?

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

Unfortunately, the provided context does not contain any information about setting the Constant QP (Quantization Parameter) encode mode in Jetson AGX Orin. The context only discusses enabling disk encryption and applying a new partition layout file using the board configuration file.

However, I can provide some general information about Constant QP encode mode and how it might be related to Jetson AGX Orin.

Constant QP encode mode is a feature in video encoding that allows the encoder to maintain a constant quality level across the entire video, rather than adjusting the quality based on the complexity of the scene. This can be useful in applications where a consistent quality level is required, such as in video conferencing or surveillance.

To set the Constant QP encode mode in Jetson AGX Orin, you would typically need to use a video encoding library or API that supports this feature. Some possible options include:

  1. NVIDIA’s Video Codec SDK (NVENC): This is a software development kit that provides a set of APIs for video encoding and decoding on NVIDIA GPUs, including the Jetson AGX Orin. The NVENC SDK supports Constant QP encode mode, and you can use it to configure the encoder to maintain a constant quality level.
  2. GStreamer: This is an open-source multimedia framework that provides a set of plugins for video encoding and decoding. GStreamer supports Constant QP encode mode, and you can use it to configure the encoder to maintain a constant quality level.
  3. FFmpeg: This is an open-source command-line tool for video encoding and decoding. FFmpeg supports Constant QP encode mode, and you can use it to configure the encoder to maintain a constant quality level.

To set the Constant QP encode mode in Jetson AGX Orin using one of these libraries or APIs, you would typically need to:

  1. Initialize the video encoder and configure it to use the Constant QP encode mode.
  2. Set the desired quality level (QP) for the encoder.
  3. Start the encoding process and provide the input video data to the encoder.

Here is an example of how you might set the Constant QP encode mode using the NVENC SDK:

// Initialize the NVENC encoder
NVENCSession session;
NVENCStatus status = NVENC_CreateSession(&session);

// Configure the encoder to use Constant QP encode mode
NVENCConfig config;
config.encodeMode = NVENC_ENCODE_MODE_CONSTANT_QP;
config.qualityLevel = 25; // Set the desired quality level (QP)

// Start the encoding process
NVENC_Encode(session, &config, inputVideoData);

Note that this is just an example, and the actual code will depend on the specific library or API you are using.

In summary, while the provided context does not contain any information about setting the Constant QP encode mode in Jetson AGX Orin, you can use video encoding libraries or APIs such as NVENC, GStreamer, or FFmpeg to configure the encoder to maintain a constant quality level.

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

ffmpeg --help full |tee ffmpeg.txt

grep -iB8 cqp ffmpeg.txt

av1_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality
--
h264_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality
--
h265_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality
--
mpeg2_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality
--
vp8_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality
--
vp9_vaapi AVOptions:
  -idr_interval      <int>        E..V....... Distance (in I-frames) between key frames (from 0 to INT_MAX) (default 0)
  -b_depth           <int>        E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  -async_depth       <int>        E..V....... Maximum processing parallelism. Increase this to improve single channel performance. (from 1 to 64) (default 2)
  -low_power         <boolean>    E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  -max_frame_size    <int>        E..V....... Maximum frame size (in bytes) (from 0 to INT_MAX) (default 0)
  -rc_mode           <int>        E..V....... Set rate control mode (from 0 to 6) (default auto)
     auto            0            E..V....... Choose mode automatically based on other parameters
     CQP             1            E..V....... Constant-quality

I’ve already shutdown Orin so can’t currently test it there but on Jetpack 7.2 on Thor following work and may be relevant to your question.

ffmpeg -h encoder=h264_nvenc

ffmpeg -i input.mp4 -c:v h264_nvenc -rc constqp -qp 18 -preset p6 -c:a copy output.mp4

ffmpeg -i input.mp4 -c:v h264_nvenc -rc constqp -qp 18 \
  -init_qpI 16 -init_qpP 18 -init_qpB 20 -preset p6 -c:a copy output.mp4

ffmpeg -i input.mp4 -c:v hevc_nvenc -rc constqp -qp 20 -preset p6 -c:a copy output_hevc.mp4

ffmpeg -i input.mp4 \
  -c:v h264_nvenc \
  -rc constqp \
  -init_qpI 16 \
  -init_qpP 18 \
  -init_qpB 20 \
  -preset p6 \
  -profile:v high \
  -c:a copy \
  output.mp4

ffmpeg -i input.mp4 \
  -c:v h264_nvenc \
  -rc constqp \
  -qp 18 \
  -preset p6 \
  -spatial-aq 1 \
  -aq-strength 8 \
  -c:a copy \
  output.mp4

Thanks, but i want to know how to set CQP using jetson_multimedia_api.

AGX Orin Dev Kit with Jetpack 7.2 r39.2.0

grep -ir qp /usr/src/jetson_multimedia_api --include=*.{h,cpp}

grep -ir ConstantQp /usr/src/jetson_multimedia_api --include=*.{h,cpp}

Hi,
Please configure the parameters in 01_video_encode sample:

/usr/src/jetson_multimedia_api/samples/01_video_encode

        --econstqp            Enable Constant QP, disabling rate control
        -qpi <i> <p> <b>      Specify initial QP params for I, P and B-frames respectively