How to use QSV in FFMPEG in Windows/linux

Source: Internet
Author: User
Tags mkdir centos superuser permission

QSV usage in FFMPEG (windows)


In Windows, Intel Media SDK in INDE is usually used instead of MMS, because the latter is only available in Linux and Windows Server.

INDE can be downloaded for free. It is recommended that you download its offline installation package because it is not required for many features. You can use the offline installation package to download the desired features.

Install Media SDK

Installing Media SDK on Windows is relatively simple. Please refer to the installation method in this link. We only use it for video encoding, so we only need to select

-Media SDK for Windows
-Media Raw Acclecerator for Windows
These two items are enough.

Compile the FFMPEG library that supports qsv in Windows

Compile mfx_dispatcher

Before compiling qsv in windows, you need to install mfx_dispatcher, which is equivalent to an intermediate layer between the application and a specific hardware acceleration Library. It is responsible for helping the application library locate the underlying code, in this way, the application library does not need to be directly linked to the specific implementation of hardware acceleration.

[Mfx_dispatcher] [] The code can be downloaded from github. The compilation method is also provided in README of github. Note that the compilation tool is the x86_64 tool chain of mingw64. If you are using the i686 tool library of mingw64, replace x86_64 in the tutorial with i686.

After mfx_dispatcher is installed, the corresponding library file and header file will be generated under/usr/i686-w64-mingw32/usr/local.

Link to FFMPEG

FFMPEG uses pkg-config to locate the libmfx Library. The libmfx. pc file of this library is installed in the/usr/i686-w64-mingw32/usr/local/lib/pkgconfig directory after mfx_dispatcher is installed. In order for the FFMPEG configure script to find it, you need to add this address to PKG_CONFIG_PATH.

Export PKG_CONFIG_PATH =/usr/i686-w64-mingw32/usr/local/lib/pkgconfig
To enable FFMPEG to support qsv, you need to add the following three configuration options:

./Configure -- enable-libmfx \
-- Enable-encoder = hsf-_qsv \
-- Enable-decoder = hsf-_qsv \
Problems that may occur during use

The Error initializing an internal MFX session Error may occur when the hsf-_qsv encoder is used. Currently, no specific cause is found. After copying the libmfxhw32.dll file under the Media SDK to the execution Directory, this problem disappears.

Use of QSV in FFMPEG (Linux)

Intel Media SDK

Now Intel no longer releases an Intel Media SDK. This component is integrated in Intel Media Server Studio on the Linux platform.

Currently, only one CentOS is recommended for the MMS version (SUSE12 is also a recommended platform in the current version ). The installation of other platforms is complex, and it is not officially recommended. Later, the introduction is based on the CentOS Operating System.

How to install MMS

First, you need to download the latest MMS version in the Intel Developer Zone. The Community version is free of charge. The installation of MMS consists of three steps.

There is an SDK2015Production * directory under the extracted folder. After switching to this directory, there is a CentOS directory. There is an intel_scripts_centos * compressed package under this directory. After extracting the compressed package, you can obtain the following three scripts:
The first two scripts are required for installation.

1. user-mode driver-UMD)

The following command requires the superuser permission:



Chown {common user name }:{ common group name}/MSS
2. Compile the driver package of the kernel space

The following command is executed with the permission of a common user:



./Build_kernel_rpm *. sh
3. Install the driver for the kernel space

Run the following command with the superuser permission:


Rpm-Uvh kernel-3.10. *. rpm

Determine whether the kernel module driver has been compiled successfully

After the system is restarted, run the following command:

Lsmod | grep 'i915'
The result is as follows:

I915 837369 4
Drm_kms_helper 44256 1 i915
Drm 294746 3 i915, drm_kms_helper
I2c_algo_b13509 1 i915
Intel_gtt 19747 1 i915
I2c_core 40683 5
I2c_i801, i915, drm_kms_helper, drm, i2c_algo_bit
Video 19785 1 i915
Button 13953 1 i915
How to compile intel qsv hardware encoder in FFMPEG

In FFMPEG, libmfx is used to implement the intel qsv hardware encoder. If you want to compile the hardware encoder, you need to add the following configuration options to compile the hardware encoder:

./Configure -- enable-libmfx \
-- Enable-encoder = hsf-_qsv \
-- Enable-decoder = hsf-_qsv \
Libmfx can not found using pkg-config

Libmfx. pc

The following error may be reported during compilation: libmfx can not found using pkg-config. This error may be caused by different causes. You need to check the config. log file in the ffmpeg root directory.

If an error is reported in this file, pkg-config cannot find the libmfx library, it is because the default installation of MMS does not provide the libmfx. pc file. You need to create this file on your own:

Sudo mkdir-p/opt/intel/mediasdk/pkgconfig

Vim/opt/intel/mediasdk/lib64/pkgconfig/libmfx. pc
Write the following content into the file:

Prefix =/opt/intel/mediasdk
Exec_prefix =$ {prefix}
Libdir =$ {exec_prefix}/lib64
Includedir =$ {exec_prefix}/include

Name: libmfxhw64

Description: Intel Media SDK dispatcher.
Version: 2015r6
Libs:-L ${libdir}-lmfxhw64
Cflags:-I $ {includedir}
Note that the libmfxhw64 Library is referenced here, because the 64-bit platform is tested.

Of course, you can create the libmfx. pc file under/usr/lib64/pkgconfig.

Mfx/mfxvideo. h

Similarly, the libmfx can not found using pkg-config command may also be a header file error. In config. log, an error is reported that the file mfx/mfxvideo. h cannot be found.

After installing MMS, mfxvideo is displayed under the/opt/intel/mediasdk/include/directory. h file, but in FFMPEG, it references mfx/mfxvideo. h header file. Therefore, an error is reported. The solution is to create a directory mfx under the/opt/intel/mediasdk/include directory, then copy the include header file to the mfx directory.

The above method can be used to correct errors that mfx/mfxvideo. h cannot find.

An error occurred while linking FFMPEG.

The MFXxxx undefinded reference error may still occur when you connect ffmpeg. At this time, you need to link your program to the lmfxhw64 Library. The simplest way is to establish a soft connection of libmfxhw64 in/usr/lib64/.

Then add the-lmfxhw64 option when compiling your own program.

Use qsv encoder in FFMPEG

Qsv Encoder contains h264 and h265 in FFMPEG. You can find this encoder through the following code.

Av_find_encoder_by_name ("h1__qsv ");
In addition, through the source file qsvenc_h264.c, we can see that it supports QSV and NV12 formats, but the QSV format does not seem to work normally. You need to set the encoding pfx_fmt to NV12.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.