Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 590752

Summary: media-video/ffmpeg absence of flags of intel qsv which are responsible for support
Product: Gentoo Linux Reporter: andrey <andrex4k>
Component: Current packagesAssignee: media-video herd <media-video>
Status: UNCONFIRMED ---    
Severity: minor CC: james05+gentoo, john5788, rboesger
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: mfx-dispatch-1.21.ebuild
ffmpeg-3.2.4.ebuild
ffmpeg-3.3.2.ebuild
mfx-dispatch-9999.ebuild

Description andrey 2016-08-08 10:55:10 UTC
lack of the flags answering for --enable-libmfx --enable-memalign-hack
Also there is no library for satisfaction of dependences of this (mfx library https://git.videolan.org/?p=mfx_dispatch.git)
Comment 1 Anton 2016-12-03 18:34:51 UTC
Intel Quick Sync Video is available since 2011, it's time to support it in Gentoo
Comment 2 John5788 2017-02-02 22:07:28 UTC
I believe we also would need to have Intel Media Server Studio in portage as a dependency for --enable-libmfx
Comment 3 Luigi 'Comio' Mantellini 2017-02-22 11:52:35 UTC
QSV support is a true nightmare:

https://blogs.gentoo.org/lu_zero/2016/10/31/intel-mediasdk-mini-walkthrough/

- Requires outdated and heavy patched libraries.
- Requires outdated kernel in order to apply all required patches.

(lu_zero is also the mfx_dispacth's mantainer https://github.com/lu-zero/mfx_dispatch)

Intel doesn't provide any kind of support on mediasdk community support.

VA-API works fine and offers the same performance level.

ciao

luigi
Comment 4 Wojciech Myrda 2017-03-27 05:14:00 UTC
(In reply to Luigi 'Comio' Mantellini from comment #3)
> QSV support is a true nightmare:
> 

Perhaps for the full support of the tools one needs Intel Media Server Studio, but for ffmpeg it says otherwise. "FFmpeg QSV support relies on libmfx" and then "Requriments on Linux: ... or use a recent enough supported system, with the libva and libdrm libraries, the libva Intel drivers, and the libmfx library packaged by lu_zero."

see here: https://trac.ffmpeg.org/wiki/HWAccelIntro#IntelQSV

Therefore adding it to Gentoo should be as easy as adding libmfx library and --enable-libmfx flag to ffmpeg.
Comment 5 Wojciech Myrda 2017-03-27 20:18:23 UTC
Created attachment 468486 [details]
mfx-dispatch-1.21.ebuild

With this ebuild QSV library downloaded and built successfully for me.
Comment 6 Wojciech Myrda 2017-03-27 20:54:39 UTC
Created attachment 468490 [details]
ffmpeg-3.2.4.ebuild

With simple addition of below

--- /usr/portage/media-video/ffmpeg/ffmpeg-3.2.4.ebuild	2017-03-20 21:24:35.000000000 +0100
+++ /usr/local/portage/media-video/ffmpeg/ffmpeg-3.2.4.ebuild	2017-03-27 22:39:35.559946221 +0200
@@ -91,7 +91,7 @@
 FFMPEG_ENCODER_FLAG_MAP=(
 	amrenc:libvo-amrwbenc mp3:libmp3lame
 	kvazaar:libkvazaar nvenc:nvenc
-	openh264:libopenh264 snappy:libsnappy theora:libtheora twolame:libtwolame
+	openh264:libopenh264 snappy:libsnappy qsv:libmfx theora:libtheora twolame:libtwolame
 	wavpack:libwavpack webp:libwebp x264:libx264 x265:libx265 xvid:libxvid
 )
 
@@ -169,6 +169,7 @@
 		nvenc? ( media-video/nvidia_video_sdk )
 		openh264? ( >=media-libs/openh264-1.4.0-r1[${MULTILIB_USEDEP}] )
 		snappy? ( >=app-arch/snappy-1.1.2-r1[${MULTILIB_USEDEP}] )
+		qsv? ( >=media-libs/mfx-dispatch-1.19[${MULTILIB_USEDEP}] )
 		theora? (
 			>=media-libs/libtheora-1.1.1[encode,${MULTILIB_USEDEP}]
 			>=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]


I got ffmpeg compiled with Intel Quick Sync Video. I used QSV as use flag as it seemed more appropriate than less understandable MFX.

BTW I was unable to find licence specific for Intel and BSD3 therefore added new one under name BSD-3-Intel in the mfx-dispatch ebuild taken from  https://github.com/lu-zero/mfx_dispatch/raw/master/COPYING
Comment 7 Wojciech Myrda 2017-04-18 05:09:48 UTC
Any particular reason why QSV has not been added to portage for new ffmpeg-3.3? You guys know it is mainly used for fast encoding not decoding right?
Comment 8 Wojciech Myrda 2017-07-03 10:42:09 UTC
Created attachment 480106 [details]
ffmpeg-3.3.2.ebuild

Not only QSV flag is not added but also there is no nvidia flag for ffmpeg. This results in cuvid being installed on PCs with Intel only platforms!

Results of USE="-nvidia qsv" emerge ffmpeg 
(unfixed ebuild)

Enabled hwaccels:
h263_vaapi              mpeg1_cuvid             vc1_cuvid
h264_cuvid              mpeg1_vdpau             vc1_vaapi
h264_vaapi              mpeg2_cuvid             vc1_vdpau
h264_vdpau              mpeg2_vaapi             vp8_cuvid
hevc_cuvid              mpeg2_vdpau             vp9_cuvid
hevc_vaapi              mpeg4_cuvid             vp9_vaapi
hevc_vdpau              mpeg4_vaapi             wmv3_vaapi
mjpeg_cuvid             mpeg4_vdpau             wmv3_vdpau


Results of USE="-nvidia qsv" emerge ffmpeg 
(fixed ebuild )

Enabled hwaccels:
h263_vaapi		mpeg1_vdpau		vc1_vaapi
h264_qsv		mpeg2_qsv		vc1_vdpau
h264_vaapi		mpeg2_vaapi		vp8_qsv
h264_vdpau		mpeg2_vdpau		vp9_vaapi
hevc_qsv		mpeg4_vaapi		wmv3_vaapi
hevc_vaapi		mpeg4_vdpau		wmv3_vdpau
hevc_vdpau		vc1_qsv

Please fix it!
Comment 9 Rajil Saraswat 2018-02-16 04:31:20 UTC
Unfortunately, it failed for me. Full report is at https://forums.gentoo.org/viewtopic-p-8184646.html

$ffmpeg  -hwaccel qsv -hwaccel_device qsv -i his_girl_friday.mpeg  -c:v h264_qsv  qsv.mkv

ffmpeg version 3.3.6 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.4.0 (Gentoo 6.4.0-r1 p1.3)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-3.3.6/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -pipe -march=native' --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-nonfree --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --disable-gmp --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --enable-network --disable-cuda --disable-cuvid --disable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --enable-vdpau --enable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --enable-libv4l2 --disable-libpulse --disable-libopencore-amrwb --disable-libopencore-amrnb --enable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --disable-libgsm --disable-mmal --disable-libmodplug --disable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libschroedinger --enable-libspeex --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-libbs2b --disable-chromaprint --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --enable-libfreetype --disable-librubberband --disable-netcdf --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-nvenc --disable-libopenh264 --disable-libsnappy --enable-libmfx --enable-libtheora --disable-libtwolame --disable-libwavpack --disable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mpeg, from 'his_girl_friday.mpeg':
  Duration: 01:31:44.17, start: 0.223733, bitrate: 4784 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2[0x1bf]: Data: dvd_nav_packet
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (ac3 (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
[h264_qsv @ 0x5585128f7fc0] Error initializing an internal MFX session: unsupported (-3)
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
Comment 10 Wojciech Myrda 2018-08-05 08:22:13 UTC
Created attachment 542452 [details]
mfx-dispatch-9999.ebuild

(In reply to Rajil Saraswat from comment #9)
> Unfortunately, it failed for me. Full report is at
> https://forums.gentoo.org/viewtopic-p-8184646.html
> 
I actually tried to encode using quick sync, but I failed with the same error You have (more in the forum). I also failed with git version which also add several new Intel platforms (see new attachment), but  maybe you or others will have more luck.

I think bunder in the forum was right and it all comes down to whether all firmware on your platform works properly or not.
Make use to check module options for your kernel version as their names change. In 4.17 it is "i915.enable_guc=2". You may also try "i915.enable_guc=-1" but it almost hanged my desktop, YMMV.