Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
710 Views

ffmpeg libmfx not found

Hi,

I'm trying to use hardware acceleration with ffmpeg on a Ubuntu server and when I'm trying to configure ffmpeg before compile, i got this error :

ERROR: libmfx not found

I'm running Ubuntu 18.10 and a i7 6700K CPU.

I follow those two procedures :

https://www.intel.com/content/www/us/en/cloud-computing/quicksync-video-ffmpeg-install-valid.html

https://software.intel.com/en-us/articles/build-and-debug-open-source-media-stack

Here are the key command and results that make me think that libmfx is ok :

$ pkg-config --list-all| grep mfx
libmfx                libmfx - Intel Media Server Studio SDK

 

$ pkg-config --modversion libmfx
16.5

 

$ pkg-config --libs libmfx
-L/opt/intel/mediasdk/lib/lin_x64 -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm Cflags: -I/opt/intel/mediasdk/include -I/usr/include/libdrm

 

$ cat /usr/lib/pkgconfig/libmfx.pc 
prefix=/opt/intel/mediasdk
exec_prefix=${prefix}
libdir=${prefix}/lib/lin_x64
includedir=${prefix}/include
Name: libmfx
Description: Intel Media Server Studio SDK
Version: 16.5
Libs: -L${libdir} -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm Cflags: -I${includedir} -I/usr/include/libdrm

 

I got the last ffmpeg sources through git and try to configure :

$ ./configure --enable-nonfree --enable-libmfx
ERROR: libmfx not found

 

I got this error in ffbuild/config.log :

check_pkg_config libmfx libmfx mfx/mfxvideo.h MFXInit
test_pkg_config libmfx libmfx mfx/mfxvideo.h MFXInit
pkg-config --exists --print-errors libmfx
check_func_headers mfx/mfxvideo.h MFXInit -L/opt/intel/mediasdk/lib/lin_x64 -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm Cflags: -I/opt/intel/mediasdk/include -I/usr/include/libdrm
test_ld cc -L/opt/intel/mediasdk/lib/lin_x64 -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm Cflags: -I/opt/intel/mediasdk/include -I/usr/include/libdrm
test_cc -L/opt/intel/mediasdk/lib/lin_x64 Cflags: -I/opt/intel/mediasdk/include -I/usr/include/libdrm
BEGIN /tmp/ffconf.gJsgAWPJ/test.c
    1   #include <mfx/mfxvideo.h>
    2   #include <stdint.h>
    3   long check_MFXInit(void) { return (long) MFXInit; }
    4   int main(void) { int ret = 0;
    5    ret |= ((intptr_t)check_MFXInit) & 0xFFFF;
    6   return ret; }
END /tmp/ffconf.gJsgAWPJ/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -fomit-frame-pointer -fPIC -pthread -L/opt/intel/mediasdk/lib/lin_x64 Cflags: -I/opt/intel/mediasdk/include -I/usr/include/libdrm -c -o /tmp/ffconf.gJsgAWPJ/test.o /tmp/ffconf.gJsgAWPJ/test.c
gcc: error: Cflags:: No such file or directory
require libmfx mfx/mfxvideo.h MFXInit -llibmfx
check_lib libmfx mfx/mfxvideo.h MFXInit -llibmfx
check_func_headers mfx/mfxvideo.h MFXInit -llibmfx
test_ld cc -llibmfx
test_cc
BEGIN /tmp/ffconf.gJsgAWPJ/test.c
    1   #include <mfx/mfxvideo.h>
    2   #include <stdint.h>
    3   long check_MFXInit(void) { return (long) MFXInit; }
    4   int main(void) { int ret = 0;
    5    ret |= ((intptr_t)check_MFXInit) & 0xFFFF;
    6   return ret; }
END /tmp/ffconf.gJsgAWPJ/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -fomit-frame-pointer -fPIC -pthread -c -o /tmp/ffconf.gJsgAWPJ/test.o /tmp/ffconf.gJsgAWPJ/test.c
gcc -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.gJsgAWPJ/test /tmp/ffconf.gJsgAWPJ/test.o -llibmfx
/usr/bin/ld: cannot find -llibmfx
collect2: error: ld returned 1 exit status
ERROR: libmfx not found

 

Well, I don't understand where could be the issue so any help and/or support will be warmly appreciated.

 

Cheers

0 Kudos
7 Replies
Highlighted
Moderator
710 Views

Hi Olivier,

After you installed the Media SDK package, the first step before ffmpeg build is to check if the MSDK was installed or built successfully.

My article has mentioned this method, the libmfx library file should be in the sub directory of /opt/intel/mediasdk, did you check it?

You have to run the Media SDK sample successfully in order to build FFmpeg.

Mark

0 Kudos
Highlighted
Beginner
710 Views

Hi Mark,

Thank you very much for your answer.

So, I restarted from a fresh Ubuntu install. I installed Media SDK package.

Then I run a sample test :

$ ./sample_multi_transcode -i::h264 ../content/test_stream.264 -o::h264 /home/test/tmp/out.h264 -hw -la

Multi Transcoding Sample Version 8.3.26.183

libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva info: va_openDriver() returns 0
Pipeline surfaces number (DecPool): 59
MFX HARDWARE Session 0 API ver 1.27 parameters: 
Input  video: AVC 
Output video: AVC 

Session 0 was NOT joined with other sessions

Transcoding started
.
Transcoding finished

Common transcoding time is 0.125532 sec
-------------------------------------------------------------------------------
*** session 0 [0x55f12af8] PASSED (MFX_ERR_NONE) 0.125434 sec, 143 frames
-i::h264 ../content/test_stream.264 -o::h264 /home/test/tmp/out.h264 -hw -la 

-------------------------------------------------------------------------------

The test PASSED

 

So far, so good.

I also copy mfx includes into mfx sub directory as described in the doc :

$ ls -l /opt/intel/mediasdk/include/mfx
total 240
-rw-r--r-- 1 root root  4320 Feb  8 13:43 mfxastructures.h
-rw-r--r-- 1 root root  4966 Feb  8 13:43 mfxaudio++.h
-rw-r--r-- 1 root root  2979 Feb  8 13:43 mfxaudio.h
-rw-r--r-- 1 root root  4627 Feb  8 13:43 mfxbrc.h
-rw-r--r-- 1 root root  4973 Feb  8 13:43 mfxcommon.h
-rw-r--r-- 1 root root  6491 Feb  8 13:43 mfxdefs.h
-rw-r--r-- 1 root root  7433 Feb  8 13:43 mfxdispatcherprefixedfunctions.h
-rw-r--r-- 1 root root  2477 Feb  8 13:43 mfxenc.h
-rw-r--r-- 1 root root 15663 Feb  8 13:43 mfxfei.h
-rw-r--r-- 1 root root  7096 Feb  8 13:43 mfxfeihevc.h
-rw-r--r-- 1 root root  2519 Feb  8 13:43 mfxjpeg.h
-rw-r--r-- 1 root root  2604 Feb  8 13:43 mfxla.h
-rw-r--r-- 1 root root  2533 Feb  8 13:43 mfxmvc.h
-rw-r--r-- 1 root root  2540 Feb  8 13:43 mfxpak.h
-rw-r--r-- 1 root root 28017 Feb  8 13:43 mfxplugin++.h
-rw-r--r-- 1 root root 11262 Feb  8 13:43 mfxplugin.h
-rw-r--r-- 1 root root  1666 Feb  8 13:43 mfxsc.h
-rw-r--r-- 1 root root  2136 Feb  8 13:43 mfxsession.h
-rw-r--r-- 1 root root 61582 Feb  8 13:43 mfxstructures.h
-rw-r--r-- 1 root root 10110 Feb  8 13:43 mfxvideo++.h
-rw-r--r-- 1 root root  5768 Feb  8 13:43 mfxvideo.h
-rw-r--r-- 1 root root  2175 Feb  8 13:43 mfxvp8.h
-rw-r--r-- 1 root root  1599 Feb  8 13:43 mfxvp9.h
-rw-r--r-- 1 root root  1147 Feb  8 13:43 mfxvstructures.h

 

Then when I want to configure ffmpeg, i got the same error message as previously :

$ ./configure --enable-libmfx --enable-nonfree

ERROR: libmfx not found

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

 

Did I missed something ?

 

Thank you very much for any assistance

0 Kudos
Highlighted
Beginner
710 Views

And same issue in the ffbuild/config.log :

BEGIN /tmp/ffconf.FEtN2H9s/test.c
    1	#include <mfx/mfxvideo.h>
    2	#include <stdint.h>
    3	long check_MFXInit(void) { return (long) MFXInit; }
    4	int main(void) { int ret = 0;
    5	 ret |= ((intptr_t)check_MFXInit) & 0xFFFF;
    6	return ret; }
END /tmp/ffconf.FEtN2H9s/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -fomit-frame-pointer -fPIC -pthread -c -o /tmp/ffconf.FEtN2H9s/test.o /tmp/ffconf.FEtN2H9s/test.c
/tmp/ffconf.FEtN2H9s/test.c:1:10: fatal error: mfx/mfxvideo.h: No such file or directory
 #include <mfx/mfxvideo.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
ERROR: libmfx not found

 

0 Kudos
Highlighted
Moderator
710 Views

Thanks Oliver,

And sorry for the late response, I was busy on the other projects.

I did FFmpeg build a while ago and can't remember all the details, but I do have an article to describe it. It was about building the ffmpeg library. It was working at that time, hope it can help:

https://software.intel.com/en-us/articles/quick-start-on-integrating-ffmpeg-libraries

Mark

0 Kudos
Highlighted
Beginner
710 Views

Hi Mark,

Thank you very much, i did manage to compile ffmpeg now :) All looks ok :)

0 Kudos
Highlighted
Beginner
710 Views

Well, FFMPEG compile but h264_qsv trigger errors :

ffmpeg -y -i /data/test_input.mp4 -pix_fmt yuv420p -c:v h264_qsv -profile:v baseline -preset fast -b:v 4000k -an /data/test_output.mp4
ffmpeg version N-93094-g7f8bfbee36 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
  configuration: --prefix=/home/tunn3l/ffmpeg_build --extra-cflags=-I/home/tunn3l/ffmpeg_build/include --extra-ldflags=-L/home/tunn3l/ffmpeg_build/lib --bindir=/home/tunn3l/bin --enable-gpl --enable-libfreetype --enable-libfontconfig --enable-libmfx --enable-nonfree --enable-libx264 --enable-decklink --extra-cflags=-I/home/tunn3l/Blackmagic_DeckLink_SDK_10.11.4/Linux/include --extra-ldflags=-L/home/tunn3l/Blackmagic_DeckLink_SDK_10.11.4/Linux/include
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 46.100 / 58. 46.100
  libavformat    58. 26.100 / 58. 26.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/test_input.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2018-07-15T19:58:54.000000Z
    firmware        : H18.01.01.00.00
  Duration: 00:05:05.88, start: 0.000000, bitrate: 30184 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 29999 kb/s, 50 fps, 50 tbr, 90k tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2018-07-15T19:58:54.000000Z
      handler_name    : 	GoPro AVC
      encoder         : GoPro AVC encoder
      timecode        : 19:58:55:26
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2018-07-15T19:58:54.000000Z
      handler_name    : 	GoPro AAC
      timecode        : 19:58:55:26
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2018-07-15T19:58:54.000000Z
      handler_name    : 	GoPro TCD
      timecode        : 19:58:55:26
    Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2018-07-15T19:58:54.000000Z
      handler_name    : 	GoPro MET
    Stream #0:4(eng): Data: none (fdsc / 0x63736466), 12 kb/s (default)
    Metadata:
      creation_time   : 2018-07-15T19:58:54.000000Z
      handler_name    : 	GoPro SOS
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Press  to stop, [?] for help
Incompatible pixel format 'yuv420p' for codec 'h264_qsv', auto-selecting format 'nv12'
[swscaler @ 0x55adeb794140] deprecated pixel format used, make sure you did set range correctly
[h264_qsv @ 0x55adeaf008c0] Current profile is unsupported
[h264_qsv @ 0x55adeaf008c0] Selected ratecontrol mode is unsupported
[h264_qsv @ 0x55adeaf008c0] Low power mode is unsupported
[h264_qsv @ 0x55adeaf008c0] Current frame rate is unsupported
[h264_qsv @ 0x55adeaf008c0] Current picture structure is unsupported
[h264_qsv @ 0x55adeaf008c0] Current resolution is unsupported
[h264_qsv @ 0x55adeaf008c0] Current pixel format is unsupported
[h264_qsv @ 0x55adeaf008c0] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Any idea ?

0 Kudos
Highlighted
Moderator
710 Views

Hi Oliver,

Glad to know the build works. For the runtime issue, MSDK uses NV12 as the pixel format, could you try "nv12".

I think yuv420p and nv12 are pretty close but they are different pix_fmt in ffmpeg, you can check all the available format with "ffmpeg -pix_fmts".

Did you have any success with QSV plugin?

Mark

0 Kudos