Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools from Intel. This includes Intel® oneAPI Video Processing Library and Intel® Media SDK.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

ffmpeg and media sdk

My current system:
OS: Ubuntu Linux  14.04 with kernel 3.14.5-MSSr6 #1 SMP.
Hardware: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
1) I managed to complete the detailed instruction for installing intel media sdk on generic Linux OS.
I followed the instruction given in
- All sample_encode works with the media sdk
2) I also compiled the latest ffmpeg from github following the procedure presented in
3) I was testing compression of video camera feed using the command

>> /opt/ffmpeg_qsv/bin/ffmpeg -f v4l2 -framerate 30 -video_size 640x480 -i /dev/video0 -c:v h264_qsv -b:v 2000k out.mp4 -loglevel 1000000
I got the following error:

[h264_qsv @ 0x2e327e0] Error initializing an internal MFX session
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Things that I tried:
1) ensure user is part of video group
2) Run the command with sudo and su
3) export LD_LIBRARY_PATH (export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/mediasdk/lib64)
4) add
/etc/ -> /opt/intel/mediasdk/lib64
5) ldconfig -p -N | grep intel.mediasdk (libc6,x86-64) => /opt/intel/mediasdk/lib64/ (libc6,x86-64) => /opt/intel/mediasdk/lib64/

6) Testing with a sample yuv file instead of camera feed got the same error

Please see the detailed log attached.

Any help to proceed next would be appreciated.
0 Kudos
2 Replies

Hi Jay, 

We have recently created a white paper on this topic i.e. configuring QSV in ffmpeg on Intel hardware which is what you are trying to set up. Your hardware seems to be supported Intel Media Server Studio and you have verified using samples, coming to set up ffmpeg and test, will recommend you to go through this paper - 
Also, it's better to start your test with a local file than a stream captured from camera, if it's work fine, move to stream captured from camera. 

Let us know if after following the white paper you still come across any issue. 



Hi Surbhi,

Thanks for the link to the paper. The instruction that I followed is pretty much similar. Also, I tested with a local file and it generated the same error.

Here is the command:

/opt/ffmpeg_qsv/bin/ffmpeg -y -i ~/software/MediaServerStudioEssentials2016/MediaSamples_Linux_2016_bin/content/test_stream.264 -vcodec h264_qsv -acodec copy -b:v 8000k ~/out.mp4

The stdout from the run is shown below:

ffmpeg version n3.0-3-gb80083a Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
  configuration: --disable-shared --enable-static --enable-gpl --enable-nonfree --enable-fontconfig --enable-libfaac --enable-libfreetype --enable-libmp3lame --enable-librtmp --enable-libx264 --enable-version3 --enable-ffplay --disable-doc --disable-ffserver --enable-pthreads --enable-filters --enable-libvorbis --enable-libtheora --enable-runtime-cpudetect --enable-libass --enable-bzlib --enable-zlib --prefix=/opt/ffmpeg_qsv/ --enable-libmfx
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[h264 @ 0x3bb1540] Increasing reorder buffer to 1
Input #0, h264, from '/home/jayram/software/MediaServerStudioEssentials2016/MediaSamples_Linux_2016_bin/content/test_stream.264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 176x96 [SAR 1:1 DAR 11:6], 30 fps, 30 tbr, 1200k tbn, 60 tbc
[h264_qsv @ 0x3bedf60] Error initializing an internal MFX session
Output #0, mp4, to '/home/jayram/out.mp4':
    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 30 fps
      encoder         : Lavc57.24.102 h264_qsv
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Like before, I got the same error "Error initializing an internal MFX session".

I followed the instruction given in for installing the libva, libdrm and libmfx from the mediasdk/opensource folder. This process is not described in the document that you shared.

Regards, Jay