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 options, 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.
Sample command:
ffmpeg -s 1920x1080 -i input.yuv -bf 0 -c:v libhw265 -wpp_threads 4 output.mp4
The command output is as follows:
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 the libhw265 encoder. |
-s |
FFmpeg built-in parameter |
Width and height of the input image. It corresponds to the command line parameters -w and -h of the libhw265 encoder. |
-vframes |
FFmpeg built-in parameter |
Number of frames to be encoded. It corresponds to the command line parameter --frames of the libhw265 encoder. |
-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 the libhw265 encoder. 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. 0: Disables the log function. 1: Enables the error output. Only error information is reported. 2: Enables the warning output. Only warning information and information below the warning level are reported. 3: Enables the info output. Only important information and information below the info level are reported. 4: Enables the debug output. Only debugging information and information below the debug level are reported. |
-frame_threads |
libhw265 encoder parameter |
Number of threads for frame-level encoding. The value range is [1, 38]. The default value is 12. It corresponds to the command line parameter --FrmThreadNum of the libhw265 encoder. |
-wpp_threads |
libhw265 encoder parameter |
Number of threads for Wavefront Parallel Processing (WPP) row-level encoding. The value range is [1, 20]. The default value is 8. It corresponds to the command line parameter --WppThreadNum of the libhw265 encoder. |
-analysis_threads |
libhw265 encoder parameter |
Number of pre-analysis threads. The value range is [1, 48]. The default value is 5. It corresponds to the command line parameter --LookAheadThreads of the libhw265 encoder. |
-adap_I |
libhw265 encoder parameter |
Enables scene-adaptive I-frames. The value range is [0, 1]. The default value is 1. It corresponds to the command line parameter --adap_i of the libhw265 encoder. |
-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 |
Encoding quality level. Available level options are 2, 3, 5, and 6. As the encoding speed increases, the encoding quality decreases. The default value is 3. It corresponds to the command line parameter --preset of the libhw265 encoder. |
-keyint |
libhw265 encoder parameter |
I-frame interval. The value is greater than or equal to 1. The default value is 150. It corresponds to the command line parameter --keyInt of the libhw265 encoder. |
-bframe_nums |
libhw265 encoder parameter |
Maximum consecutive B-frames. The value range is [0, 7]. The default value is 7. It corresponds to the command line parameter --bframes of the libhw265 encoder. |
-delay |
libhw265 encoder parameter |
Number of frames buffered for temporal analysis. The recommended value range is [bframes, 150]. The default value is 25. It corresponds to the command line parameter --delay of the libhw265 encoder. |
-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 the libhw265 encoder. |
-qp |
libhw265 encoder parameter |
Quantization parameter (QP). A smaller value indicates a smaller quantization step size and higher precision. The data volume may be larger for the same visual image quality. The value range is [1, 51]. The default value is 18. This parameter is valid only in the CQP mode. |
-abr_bitrate |
libhw265 encoder parameter |
Average bit rate. 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 the libhw265 encoder. This parameter is valid only in the ABR mode. |
-crf |
libhw265 encoder parameter |
CRF level. The value range is [0, 51]. If the value is out of the range, the default value 23 is used. Generally, a smaller CRF value indicates higher image quality. It corresponds to the command line parameter --crf of the libhw265 encoder. This parameter is valid only in the CRF mode. |
