Examples of Using HW265Enc in FFmpeg
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 in FFmpeg.
When you enter command line parameters, the output file name must be written at the end, and other FFmpeg built-in parameters must be written after the ffmpeg command. The libhw265 encoder parameters are written after libhw265. Parameter types and descriptions are shown in Table 1.
Command example:
ffmpeg -s 1920x1080 -i input.yuv -bf 0 -c:v libhw265 -wpp_threads 4 output.mp4
Information similar to the following is displayed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Input #0, rawvideo, from 'input.yuv': Duration: 00:01:00.00, start: 0.000000, bitrate: 622080 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080 kb/s, 25 tbr, 25 tbn, 25 tbc File 'output.mp4' already exists. Overwrite ? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> hevc (libhw265)) Press [q] to stop, [?] for help Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: hevc (libhw265) (hev1 / 0x31766568), yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc58.54.100 libhw265 frame= 1500 fps= 13 q=-0.0 Lsize= 34439kB time=00:00:58.96 bitrate=4785.1kbits/s speed=0.504x video:34432kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.020906% |
FFmpeg Command Line Parameter |
Parameter Type |
Description |
|---|---|---|
-i |
FFmpeg built-in parameter |
Name of the input file. It corresponds to the command line parameter -i of CloudHw265App. |
-s |
FFmpeg built-in parameter |
Width and height of the input image. It corresponds to the command line parameters -w and -h of CloudHw265App. |
-vframes |
FFmpeg built-in parameter |
Number of frames to be encoded. It corresponds to the command line parameter --frames of CloudHw265App. |
-fps_num |
libhw265 encoder parameter |
Frame rate of the output video. The value range is (0, 120]. If the value does not fall within the range, the default value 25 is used. It corresponds to the command line parameter --fps_num of CloudHw265App. In this case, the default value of fps_den is 1. |
-channel |
libhw265 encoder parameter |
ID of the current encoder. The encoder ID is used to identify different encoders. The default value is 0. |
-log_level |
libhw265 encoder parameter |
Encoder log output level. The default value is 1.
|
-frame_threads |
libhw265 encoder parameter |
Number of threads for frame-level encoding. A larger value indicates a higher encoding speed. The value range is [1, 38] and the default value is 12. If this parameter is set to a value outside the range, the default value is used or an error is reported. It corresponds to the command line parameter --FrmThreadNum of CloudHw265App. |
-wpp_threads |
libhw265 encoder parameter |
Number of threads for WPP row-level encoding. A larger value indicates a higher encoding speed. The value range is [1, 20] and the default value is 8. It corresponds to the command line parameter --WppThreadNum of CloudHw265App. |
-analysis_threads |
libhw265 encoder parameter |
Number of threads for pre-analysis. Pre-analysis scans the upcoming frames in advance, which improves the encoding image quality but increases the encoding latency. The value range is [1, 48] and the default value is 5. It corresponds to the command line parameter --LookAheadThreads of CloudHw265App. |
-adap_I |
libhw265 encoder parameter |
Specifies whether to enable scene-adaptive I-frame insertion. If this function is enabled, the encoding quality is improved but the encoding speed decreases. The value range is [0, 1] and the default value is 1. If this parameter is set to a value outside the range, the default value is used. It corresponds to the command line parameter --adapt_i of CloudHw265App. |
-profile |
libhw265 encoder parameter |
Encoding complexity of the HW265 encoder. Only the main profile is supported. The default value is 0. |
-qualityset |
libhw265 encoder parameter |
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. It corresponds to the command line parameter --preset of CloudHw265App. |
-keyint |
libhw265 encoder parameter |
I-frame interval. Typically, a larger value indicates lower image quality and faster encoding. The value is greater than or equal to 1. The default value is 150. It corresponds to the command line parameter --keyInt of CloudHw265App. |
-bframe_nums |
libhw265 encoder parameter |
Maximum consecutive B-frames. Typically, a larger value indicates higher image quality and slower encoding at the same bit rate. The value range is [0, 7] and the default value is 7. It corresponds to the command line parameter --bframes of CloudHw265App. |
-delay |
libhw265 encoder parameter |
Number of frames buffered for time-domain analysis. Typically, a larger value indicates higher image quality and slower encoding at the same bit rate. The value range is [bframes, 150] and the default value is 25. It corresponds to the command line parameter --delay of CloudHw265App. |
-rc |
libhw265 encoder parameter |
Bit rate control policy. The value can be 0, 1, and 2, indicating constant quantization parameter (CQP), average bit rate (ABR), and constant quality factor (CRF), respectively. If the value does not fall within the range, the default value 0 is used. It corresponds to the command line parameter --rc of CloudHw265App. |
-qp |
libhw265 encoder parameter |
Quantization parameter (QP). Typically, a smaller value indicates a smaller quantization step size and higher precision. The output data volume may be larger for the same visual quality. The value range is [1, 51] and the default value is 18. This parameter is valid only in the CQP mode. |
-abr_bitrate |
libhw265 encoder parameter |
Average bit rate. Typically, a larger value indicates higher image quality and slower encoding. The value range is [40, 300000], in kbit/s. If the value is out of the range, the default value 2000 is used. It corresponds to the command line parameter --br of CloudHw265App. This parameter is valid only in the ABR mode. |
-crf |
libhw265 encoder parameter |
CRF level. Typically, a smaller value indicates a higher bit rate and image quality but slower encoding. The value range is [0, 51]. If the value is out of the range, the default value 23 is used. It corresponds to the command line parameter --crf of CloudHw265App. This parameter is valid only in the CRF mode. |
-cfps |
libhw265 encoder parameter |
Specifies whether to set a constant frame rate. 0: no; 1: yes. The default value is 1. If this parameter is set to a value outside the range, the default value is used. It corresponds to the command line parameter -vfrinput of CloudHw265App, with inverse functionality. |
-enablefixedIdrPeriod |
libhw265 encoder parameter |
Specifies whether a fixed interval always contains an I-frame. This parameter takes effect only when -adap_I is enabled. 0: no; 1: yes. The default value is 0. This parameter does not have a corresponding CloudHw265App command line parameter. |
-bitratePar |
libhw265 encoder parameter |
Peak-to-average bit rate ratio. The value range is [1, 20] and the default value is 4. If this parameter is set to a value outside the range, the default value is used. It corresponds to the command line parameter -BitRatePAR of CloudHw265App. |
-bitrateParCtrlStrength |
libhw265 encoder parameter |
Peak control strength. The value range is [0, 3] and the default value is 0. If this parameter is set to a value outside the range, the default value is used. It corresponds to the command line parameter -ParCovStrength of CloudHw265App. |
-enableResetBitrate |
libhw265 encoder parameter |
Specifies whether to enable bit rate resetting. 0: no; 1: yes. The default value is 0. It corresponds to the command line parameter -dynamicBitrateMode of CloudHw265App. If the value is 0, the bit rate is not reset. |
-bframe_ref |
libhw265 encoder parameter |
Specifies whether to use the B-frame as the reference frame. 0: no; 1: yes. The default value is 1. If this parameter is set to a value outside the range, the default value is used. It corresponds to the command line parameter -bframeRef of CloudHw265App. |
-MbTree |
libhw265 encoder parameter |
Specifies whether to enable the MBTree bit rate control algorithm to intelligently allocate the bit rate based on the macroblock importance. 0: no; 1: yes. The default value is 1. If this parameter is set to a value outside the range, the default value is used. This parameter does not have a corresponding CloudHw265App command line parameter. |
-delayTime |
libhw265 encoder parameter |
Time-domain analysis wait time. The value range is [0, 4000] and the default value is 0. It corresponds to the command line parameter -TotalDelayTime of CloudHw265App. |
-enableDelayTimeControl |
libhw265 encoder parameter |
Specifies whether to enable time-domain analysis wait time control. 0: no; 1: yes. The default value is 0. If this parameter is set to a value outside the range, the default value is used. This parameter does not have a corresponding CloudHw265App command line parameter. |
-adap_B |
libhw265 encoder parameter |
Sets the adaptive B-frame algorithm. Available options are 0 (disabled), 1 (fastest adaptation), 2 (fast adaptation), and 3 (TRELLTS-based adaptation). The default value is 1. If this parameter is set to a value outside the range, the default value is used. This parameter does not have a corresponding CloudHw265App command line parameter. |
