Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 778875 - media-video/ffmpeg: add qsv use flag (Intel Quick Sync Video)
Summary: media-video/ffmpeg: add qsv use flag (Intel Quick Sync Video)
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 2 votes (vote)
Assignee: media-video herd
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 590752
  Show dependency tree
 
Reported: 2021-03-28 09:48 UTC by Reva Denis
Modified: 2021-04-14 19:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
example changes (example_changes.patch,1.43 KB, patch)
2021-03-28 09:49 UTC, Reva Denis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Reva Denis 2021-03-28 09:48:41 UTC
In Gentoo there are bug https://bugs.gentoo.org/590752 which reports absense of that, but it not about adding, so I create new ones.

FFMPEG already have good support for QSV maintained directly by Intel. Also in Gentoo tree there are all necessary depends.

All required changes in ebuild is listed in additional information:



Reproducible: Always




--- /var/db/repos/gentoo/media-video/ffmpeg/ffmpeg-4.3.1.ebuild 2020-12-25 07:39:23.000000000 +0500
+++ ffmpeg-4.3.1-r1.ebuild      2020-07-28 15:30:50.000000000 +0500
@@ -91,6 +91,9 @@
                libsoxr
                # Threads; we only support pthread for now but ffmpeg supports more
                +threads:pthreads
+               # Intel Quick Sync Video
+               qsv:libmfx
+
 )
 
 # Same as above but for encoders, i.e. they do something only with USE=encode.
@@ -172,6 +175,9 @@
 
 RDEPEND="
        alsa? ( >=media-libs/alsa-lib-1.0.27.2[${MULTILIB_USEDEP}] )
+       amd64? (
+               qsv? ( >=media-libs/intel-mediasdk-20.1.1 )
+               )
        amr? ( >=media-libs/opencore-amr-0.1.3-r1[${MULTILIB_USEDEP}] )
        bluray? ( >=media-libs/libbluray-0.3.0-r1:=[${MULTILIB_USEDEP}] )
        bs2b? ( >=media-libs/libbs2b-3.1.0-r1[${MULTILIB_USEDEP}] )
@@ -314,6 +320,7 @@
        cuda? ( video_cards_nvidia )
        libv4l? ( v4l )
        fftools_cws2fws? ( zlib )
+       qsv? ( abi_x86_64 )
        test? ( encode )
        ${GPL_REQUIRED_USE}
        ${CPU_REQUIRED_USE}"

 MULTILIB_WRAPPED_HEADERS=(
@@ -396,7 +401,7 @@
 
        # (temporarily) disable non-multilib deps
        if ! multilib_is_native_abi; then
-               for i in frei0r librav1e libzmq ; do
+               for i in frei0r libmfx librav1e libzmq ; do
                        myconf+=( --disable-${i} )
                done
        fi
Comment 1 Reva Denis 2021-03-28 09:49:33 UTC
Created attachment 695232 [details, diff]
example changes
Comment 2 Reva Denis 2021-03-28 09:50:45 UTC
QSV is not supported for ABI_X86_32.
Comment 3 Leho Kraav (:macmaN @lkraav) 2021-04-14 14:58:45 UTC
I'm getting "invalid atom in RDEPEND abi_x86_64" with `+       qsv? ( abi_x86_64 )`. Is this the correct constraint definition location?
Comment 4 Reva Denis 2021-04-14 15:51:28 UTC
>Is this the correct constraint definition location?

Absolutely not. It should be in REQUIRED_USE

  qsv? ( abi_x86_64 )


look carefully:
        libv4l? ( v4l )
        fftools_cws2fws? ( zlib )
+       qsv? ( abi_x86_64 )
Comment 5 Leho Kraav (:macmaN @lkraav) 2021-04-14 19:56:23 UTC
Beautiful, it all works.

Figured out a cmdline that dropped `gphoto2 --capture-movie` CPU usage from 28% -> 8%

```
$ gphoto2 --stdout --capture-movie | ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v mjpeg_qsv -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
```

I'm a complete ffmpeg - can this cmdline be optimized further?

For example, a more clear (to a newb eye) parameter set produced an format conversion error:

```
$ ... | ffmpeg -hwaccel qsv -c:v mjpeg_qsv -i - ...
```

Slightly off-topic perhaps, but I'd really like to know why that magic-like `-init_hw_device` stuff works, and `-hwaccel -c:v` combo doesn't.