Rate This Document
Findability
Accuracy
Completeness
Readability

Using HW265Enc

The following uses the conversion from a YUV file to an MP4 file as an example to describe how to use the encoding commands of HW265Enc.

Use HW265Enc to encode test.yuv and output the encoded file to test.mp4. The following is an example of the encoding command:
./bin/CloudHw265App -c ~/dependency/lib/cfg/hw265_encoder.cfg -preset 6 -w 1920 -h 1080 -rc 0 -br 8000 -pass 0 -fps_num 30 -fps_den 1 -timebase_den 30 -timebase_num 1 -frames 9999 -keyInt 120 -adap_i 0 -bframes 3 -delay 4 -FrmThreadNum 4 -WppThreadNum 4 -LookAheadThreads 3 -i test.yuv -b test.mp4

When HW265Enc is used, the configurable parameters are shown in Table 1.

Information similar to the following is displayed:

ShortInterfacr Mode: current version is LOG-iMedia Video III 5.5.1.B001, 10:57:09  Apr 18 2025, 10
Input YUV file    : test.yuv
Output stream file: test.mp4
Begin encoding: test.yuv res 1920x1080
Total Frames: 600, init encode time: 44ms, del encode time: 70ms, pure time: 11459ms, FPS: 52.3601
bitrate: 7965.0008
Total Time: 11960ms, TotalFps: 50.1643
Encoding CpuUsage:      5.43%
Encode Success!!
Table 1 HW265Enc command line parameters

Parameter

Description

Command Line Example

-v

Queries version information.

-v

-h

Lists all options.

-h

-c <string>

Indicates the path to the configuration file.

-c ~/dependency/lib/cfg/hw265_encoder.cfg

-preset <integer>

Sets the encoding quality level. Available level options are 2, 3, 5, and 6. The encoding speed increases with each level, while the corresponding encoding quality decreases. The default value is 3.

-preset 6

-i <string>

Inputs the YUV 4:2:0 file.

-i input.yuv

-b <string>

Outputs the bitstream file.

-b output.bit

-frames <integer>

Indicates the number of frames to be encoded.

-frames 1000

-channel <integer>

Indicates the channel ID of the encoder.

-channel 1

-w <integer>

Indicates the image width (in pixels). The value range is [160, 4096].

-w 1920

-h <integer>

Indicates the image height (in pixels). The value range is [96, 4096].

-h 1080

-keyInt <integer>

Indicates the keyframe interval. The value range is [0, 65535].

  • 0: Only the first frame is an I-frame.
  • 1: All frames are I-frames.

-keyInt 30

-rc <integer>

Indicates the rate control mode.

  • 0: average bit rate (ABR)
  • 1: constant rate factor (CRF)

-rc 0

-br <integer>

Indicates the target bit rate (kbit/s). The value range is [40, 300000].

-br 5000

-crf <integer>

Sets a CRF value. The value range is [0, 51]. The default value is 23. This parameter is valid only in the CRF mode.

-crf 23

-delay <integer>

Sets the number of frames buffered for time-domain analysis. The value range is [0, 150].

-delay 4

-FrmThreadNum <integer>

Sets the number of threads for frame-level encoding. The value range is [1, 38].

-FrmThreadNum 4

-WppThreadNum <integer>

Sets the number of threads for Wavefront Parallel Processing (WPP) row-level encoding. The value range is [1, 20].

-WppThreadNum 4

-LookAheadThreads <integer>

Sets the number of lookahead pre-analysis threads. The value range is [1, 48].

-LookAheadThreads 4

-sar_width <integer>

Indicates the sampling aspect ratio. The value range is [0, 65535].

-sar_width 1

-sar_height <integer>

Indicates the sampling aspect ratio. The value range is [0, 65535].

-sar_height 1

-qual_enh_mode <integer>

Indicates the quality enhancement mode. The value range is [0, 4].

-qual_enh_mode 2

-qual_enh_level <integer>

Indicates the quality enhancement level. The value range is [1, 8].

-qual_enh_level 4

-qual_enh_thread_num <integer>

Indicates the number of quality enhancement threads.

-qual_enh_thread_num 4

-pass <integer>

Specifies whether to enable multi-pass encoding.

  • 0: No
  • 1: First pass
  • 2: Second pass

-pass 0

-fps_num <integer>

Indicates the numerator of the frame rate.

-fps_num 30

-fps_den <integer>

Indicates the denominator of the frame rate (forming the frame rate with the numerator, for example, 30/1).

-fps_den 1

-timebase_num <integer>

Indicates the numerator of the time base.

-timebase_num 1

-timebase_den <integer>

Indicates the denominator of the time base (forming the time base with the numerator, for example, 1/30. The time base is the reciprocal of the frame rate).

-timebase_den 30

-adap_i <integer>

Specifies whether to enable scene-adaptive I-frames.

  • 0: No
  • 1: Yes

-adap_i 0

-bframes <integer>

Indicates the maximum consecutive B-frames. The value range is [0, 7].

-bframes 3