Using x265
You can use FFmpeg to invoke x265 in your video encoding operations.
- Add the environment variables of the dependency libraries.
export LD_LIBRARY_PATH=/home/ffmpeg/install/lib:/home/x265/install/lib export PKG_CONFIG_PATH=/home/x265/install/lib/pkgconfig/
- Convert the MP4 media format to YUV.
/home/ffmpeg/install/bin/ffmpeg -i input.mp4 output.yuv
- Run the encoding program. Table 1 describes the parameters.
/home/ffmpeg/install/bin/ffmpeg -s 1920x1080 -framerate 60 -i output.yuv -preset medium -c:v libx265 -x265-params "bitrate=2000:vbv-maxrate=2000:vbv-bufsize=2000:numa-pools='2,-,-,-'" -f null /dev/null > "log.txt" 2>&1
Table 1 Parameters of the encoding program Parameter
Description
/home/ffmpeg/install/bin/ffmpeg
Specifies the path of the FFmpeg executable file. Replace this example path with the actual one.
-s 1920x1080
Sets the resolution of the output video to 1920x1080.
-framerate 60
Sets the frame rate of the output video to 60 fps.
-i input.yuv
Specifies the name and path of the input file.
-preset medium
Sets the preset option of video encoding to medium. This parameter affects the encoding speed and compression efficiency.
-c:v libx265
Uses the libx265 encoder to encode videos.
-x265-params "bitrate=2000:vbv-maxrate=2000:vbv-bufsize=2000:numa-pools='2,-,-,-'"
Sets the parameters of the x265 encoder, including the bit rate, maximum bit rate, buffer size, and NUMA memory pool. The meanings of the parameters following numa-pools are as follows:
- The input frame uses NUMA node 2.
- The output frame uses the default NUMA node, which is indicated by the hyphen (-).
- Other computing tasks use the default NUMA node, which is indicated by the hyphen (-).
The preceding parameter setting enables libx265 to better use the resources of the NUMA architecture for improved performance.
If your system does not use the NUMA architecture or you are not familiar with NUMA, you can keep the default for the numa-pools parameter, for example, numa-pools='-, -,-,-',. Alternatively, you can choose not to add this parameter.
-f null /dev/null
Sets the output format as null and redirects the output to /dev/null. This setting actually discards the output because /dev/null in the command line indicates an empty device and does not save any output. In comparison, -f mp4 output.mp4 indicates that the output file is in the MP4 format.
> "log.txt"
Redirects the standard output to the log.txt file.
2>&1
Redirects the standard error output to the same place as the standard output, that is, to the log.txt file.