EN|CN
Cambricon® FFmpeg-MLU supports hardware-accelerated video decoding and encoding using a plain C API on Cambricon MLU hardware platforms.
- Supported OS:
- Ubuntu
- Centos
- Debian
- Cambricon MLU Driver:
- neuware-mlu270-driver-4.0.3 or later.
- Cambricon MLU SDK:
- neuware-mlu270-1.2.5-1 or later.
-
Get FFmpeg sources and patch with the following Git* command:
git clone https://gitee.com/mirrors/ffmpeg.git -b release/4.2 --depth=1 cd ffmpeg git apply ../ffmpeg4.2_mlu.patch -
If you are using CentOS, you need to set
LD_LIBRARY_PATHto the proper directory by running the following commands:export LD_LIBRARY_PATH=/usr/local/neuware/lib64 -
Run the following commands to configure and build FFmpeg-MLU:
./configure --enable-gpl \ --enable-version3 \ --enable-mlumpp \ --extra-cflags="-I/usr/local/neuware/include" \ --extra-ldflags="-L/usr/local/neuware/lib64" \ --extra-libs="-lcncodec -lcnrt -ldl" make -j -
If you need a MLU transcode demo with multi-threads, run the following commands:
make -j examples
-
(Optional) If you need support downscaling with MLU operators, build
mluop_pluginand copylibeasyOP.soto the/usr/local/neuware/lib64folder.
Supported video decoding formats are as follows:
- H.264/AVC
- Codec Name:
h264_mludec
- Codec Name:
- HEVC
- Codec Name:
hevc_mludec
- Codec Name:
- VP8
- Codec Name:
vp8_mludec
- Codec Name:
- VP9
- Codec Name:
vp9_mludec
- Codec Name:
- JPEG
- Codec Name:
mjpeg_mludec
- Codec Name:
Example
export LD_LIBRARY_PATH=/usr/local/neuware/lib64
./ffmpeg -c:v h264_mludec -i input_file -f null -Supported video encoding formats are as follows:
- H.264/AVC
- Codec Name:
h264_mluenc
- Codec Name:
- HEVC
- Codec Name:
hevc_mluenc
- Codec Name:
Example
export LD_LIBRARY_PATH=/usr/local/neuware/lib64
./ffmpeg -i input_file -c:v h264_mluenc <output.h264>./ffmpeg -benchmark -re -i input.mkv -c:v h264_mluenc -f null -./ffmpeg -y -vsync 0 -c:v h264_mludec -i input_1920x1080.mkv -vf scale=320:240 output_320x240.mp4./ffmpeg -y -vsync 0 -c:v h264_mludec -i fhd_input.mkv -c:a copy -c:v h264_mluenc -b:v 5M output.mp4
./ffmpeg -y -vsync 0 -c:v h264_mludec -i fhd_input.mkv -vf scale=1280:720 -c:a copy -c:v h264_mluenc -b:v 2M output1.mp4 -vf scale=640:360 -c:a copy -c:v h264_mluenc -b:v 512K output2.mp4This section introduces how to test video quality with PSNR and SSTM.
./ffmpeg -i src.h264 -i dst.h264 -lavfi psnr="stats_file=psnr.log" -f null -./ffmpeg -i src.h264 -i dst.h264 -lavfi ssim="stats_file=ssim.log" -f null -This section introduces how to improve the performance.
| Option name | Type | Description |
|---|---|---|
| device_id | int | Select the accelerator card. Supported values range from 0 to INT_MAX. INT_MAX is the total number of accelerator cards minus 1. The default value is 0. |
| instance_id | int | Select the VPU instance. Supported values are: - Value in the range 0 - 5: Represents VPU instance. - 6: The VPU instance is auto-selected. The default value is 6. |
| cnrt_init_flag | int | Initialize or destory cnrt context in FFmpeg. Supported values are: - 0: Represents disabled. - 1: Represents enabled. The default value is 1. |
| input_buf_num | int | Number of input buffers for decoder. Supported values range from 1 to 32. The default value is 5. |
| output_buf_num | int | Number of output buffers for decoder. Supported values range from 1 to 32. The default value is 6. |
| stride_align | int | Stride align of output buffers for decoder. Supported values range from 1 to 128, can be 2^(0 - 7). The default value is 1. |
| output_pixfmt | int | The output pixel format. Supported values are: - 0: Represents NV12. - 1: Represents NV21. - 2: Represents I420. The default value is 0. |
| resize | string | Resize (width)x(height). Only supports 1/2 and 1/4 for down scaling. The default is null. |
| trace | int | MLU FFmpeg MLU trace switch. Supported values are: - 0: Represents disabled. - 1: Represents enabled. The default value is 0. |
| Option name | Type | Description |
|---|---|---|
| device_id | int | Select the accelerator card. Supported values range from 0 to INT_MAX. INT_MAX is the total number of accelerator cards minus 1. The default value is 0. |
| instance_id | int | Select the VPU instance. Supported values are: - Value in the range 0 - 1: Represents VPU instance. - 6: The VPU instance is auto-selected. The default value is 6. |
| cnrt_init_flag | int | Initialize or destory cnrt context in FFmpeg. Supported values are: - 0: Represents disabled. - 1: Represents enabled. The default value is 1. |
| input_buf_num | int | Number of input buffers for encoder. Supported values range from 1 to 32. The default value is 3. |
| output_buf_num | int | Number of output buffers for encoder. Supported values range from 1 to 32. The default value is 5. |
| trace | int | MLU FFmpeg debug switch. Supported values are: - 0 Represents disabled. - 1: Represents enabled. The default value is 0. |
| init_qpP | int | Initial QP value for P frame, set P frame QP. Supported values range from -1 to 51. The default value is -1. |
| init_qpI | int | Initial QP value for I frame, set I frame QP. Supported values range from -1 to 51. The default value is -1. |
| init_qpB | int | Initial QP value for B frame, set B frame QP. Supported values range from -1 to 51. The default value is -1. |
| qp | int | Constant QP rate control method, same as FFmpeg cqp. Supported values range from -1 to 51. The default value is -1. |
| vbr_minqp | int | Variable bitrate mode with MinQP, same as FFmepg qmin. Supported values range from -1 to 51. The default value is -1. |
| vbr_maxqp | int | Variable bitrate mode with MaxQP, same as FFmpeg qmax. Supported values range from -1 to 51. The default value is -1. |
| Option name | Type | Description |
|---|---|---|
| profile | const | Set the encoding profile. Supported values are: baseline, main, high, and high444p. The default value is high. |
| level | const | Set the encoding level restriction. Supported values are: in the range 1 - 5.1, or auto. The default value is 4.2. |
| coder | const | Set the encoding entropy mode. Supported values are: cabac and cavlc. The default value is cavlc. |
| Option name | Type | Description |
|---|---|---|
| profile | const | Set the encoding profile. Supported values are: main, main_still, main_intra, and main10. The default value is main. |
| level | const | Set the encoding level restriction. Supported values are: in the range 1 - 6.2, or auto. The default value is 1. |