You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for GNU/Linux VAAPI (AMD, Intel, ..) HW-Encoding #1083
@jstebbins@sr55 currently working on this item .. on top of ffmpeg + nvenv-encoder branch
Edit: Might support VAAPI based h264, hevc and vp8/vp9 encoding.
Not so sure about the latter vp8/vp9 though, but some support seems to be available in ffmpeg sources.
@sr55 Wouldn't it make more sense to have a single code path for both Intel and AMD (and NVIDIA via vdpau-to-vaapi wrapper library)? Intel fully supports VAAPI as far as I know. Also, VAAPI should work on non-x86 architectures while libmfx is x86-only.
It wouldn't be a single code path though. You need separate implementations for Windows and Mac.
Also, general purpose API's tend to have problems. VT on Mac cripples the hardware encoders feature set, DXVA on windows is horrifically unreliable and in areas, fundamentally broken for example.
So, I'd then ask the questions:
Does VA-API support the full feature set of these encoders, including the filters and do we actually have up-to-date driver support (the intel site doesn't indicate support for Kaby/Coffee lake features for example)
Is it actually reliable?
Does it support zero-copy?
Since we need libmfx and the nvidia/vce sdks's via ffmpeg anyway for Windows, everything should just use those same paths so we have consistent behaviour on all platforms. That's easier to support.
We already have a wrapper around using libav encoders, so it's not a giant leap to extend that and use ffmpeg/libav's built-in support that already exists.
QuickSync is Intel Only, so it doesn't matter that it's x86 only library. Also, we don't formally support or have any intention of supporting any other hardware platforms. (Supporting what we already do is a stretch for a project with limited resources)
added initial pull #1111 @sr55 your questions are partly answered and repeated/extended in the commit and pull request
It is a work in progress (WIP) and we need to solve the question I asked first :)
I believe it could become a nice added feature when it properly supports AMD and Intel.
On Debian 9.3 'stretch' I was able to get some results on AMD (erratic) and Intel (working but big file size, 'normal' as I have read)
Edit: I may add that primary motivation for VAAPI support is due to enabling AMD hw encoding using the open-source driver.
I agree with your assessment that generic API's need good maturity to compete with specific solutions, like QuickSync (Intel).
Therefor allowing VAAPI in HB (when it's working) in parallel to specific solutions might be desired. Only when VAAPI reaches parity with the individual encoding API one might consider its retirement.
Closing in favour of sticking to native support.
Nvenc and quicksync both have support on Linux. AMF looks like it might add support too so we'll pick that up when available.
@jstebbins I have updated my vaapi work in hw-encoder-vaapi
(as well as general hw-encoder-base and hw-encoder-nvenc - all names of my new branches).
Please feel free to comment, pick, merge ..
The usual TODO: I still have some hardcoded features in vaapi and nvenc,
which I like to have added to the extra-options field.
To enable this for the vaapi/nvenc codecs and have it stored in presets,
I need a little help from you.
Detailed description in the vaapi commit message,
working quite well on a AMD NAVI10 using my mesa-vaapi patch.
Notable, using vaapi with Handbrake (utilizing the hardcoded soft-frame -> NV12 -> VAAPI)
is faster than ffmpeg commandline: ~150 fps -> ~200 fps
I compared quality differences with x264 ~5Mbit/s and while I couldn't see
any visually really, PSNR and SSIM difference to orig were below 1%.
As usual, great job of all of you working on Handbrake!
I regularly use it, hence my sporadic contributions.
Will help with integration, if intended by your team.
I could get vaapi_h264 going on an AMD Renoir based APU (7400U). HEVC, VP8 and 9 are just logged with "No usable encoding profile found". VCN should support HEVC encoding.
As usual, some hardcoded parameter exist, as I still wait for UI support
to add additional encoder parameter.
Perhaps one day this gets merged ;-)
I just use this branch for encoding jobs, leaving the CPU cool.
Nice TODO: Test on weak platforms but with VAAPI hw encoder.
Note on Mesa: Works with latest git master, haven't checked
in which mesa release the following patches were added:
file: src/gallium/frontends/va/config.c
Please reopen. There are several problems with the AMD proprietary drivers:
They only work on Ubuntu LTS, RHEL or SLES- enterprise distros. Ubuntu aside, Last I checked SLES and RHEL are NOT free and CANNOT be legally downloaded by most people (only trial is available for SLES, RHEL meanwhile is blocked behind a paywall). The Ubuntu version is fine-tuned for Ubuntu LTS. Trying to install on a non-LTS version of Ubuntu will make very bad things happen (trust me, I've broke a Ubuntu system by installing the proprietary driver on a non-LTS Ubuntu. Black screen and lock up, change VT to get a text based terminal stopped working).
Continuing on the fact above, you cannot use proprietary drivers if you run Arch, Sabayon, Gentoo, etc.
The performance are subpar for gaming. Increased stuttering and lower frame rates have been observed.
Reacted by frumble, niktss, yao mtc, Sunner, Pablo, Prajna Sariputra, Theo Baumgartner, Dennis E. Mungai , Charles Edward Haithcock JR and Teuwu
From time to time I merge and update my branches, saving some CPU power when I need to transcode our video archive. However, I would love to see this merger but looks like this is the bottom of the priority.
Next update from my side with Debian Bullseye, hopefully the Mesa3D patches are all included in the distribution by then.
I Would like to see it merged too to be honest. Vaapi is the "standard"
may be it's not better than amf and nvenc but I feel like ir has to be
inside to be used by most people
El vie., 23 jul. 2021 1:46 a. m., Sven Gothel ***@***.***>
escribió:
Activity
sr55 commentedon Dec 28, 2017
Intel QuickSync should, in theory, work through mfx via ffmpeg/libav so I would avoid a second code path for that.
sgothel commentedon Dec 29, 2017
@jstebbins @sr55 currently working on this item .. on top of ffmpeg + nvenv-encoder branch
Edit: Might support VAAPI based h264, hevc and vp8/vp9 encoding.
Not so sure about the latter vp8/vp9 though, but some support seems to be available in ffmpeg sources.
rathann commentedon Dec 29, 2017
@sr55 Wouldn't it make more sense to have a single code path for both Intel and AMD (and NVIDIA via vdpau-to-vaapi wrapper library)? Intel fully supports VAAPI as far as I know. Also, VAAPI should work on non-x86 architectures while libmfx is x86-only.
sr55 commentedon Dec 29, 2017
It wouldn't be a single code path though. You need separate implementations for Windows and Mac.
Also, general purpose API's tend to have problems. VT on Mac cripples the hardware encoders feature set, DXVA on windows is horrifically unreliable and in areas, fundamentally broken for example.
So, I'd then ask the questions:
Since we need libmfx and the nvidia/vce sdks's via ffmpeg anyway for Windows, everything should just use those same paths so we have consistent behaviour on all platforms. That's easier to support.
We already have a wrapper around using libav encoders, so it's not a giant leap to extend that and use ffmpeg/libav's built-in support that already exists.
QuickSync is Intel Only, so it doesn't matter that it's x86 only library. Also, we don't formally support or have any intention of supporting any other hardware platforms. (Supporting what we already do is a stretch for a project with limited resources)
sgothel commentedon Jan 12, 2018
added initial pull #1111
@sr55 your questions are partly answered and repeated/extended in the commit and pull request
It is a work in progress (WIP) and we need to solve the question I asked first :)
I believe it could become a nice added feature when it properly supports AMD and Intel.
On Debian 9.3 'stretch' I was able to get some results on AMD (erratic) and Intel (working but big file size, 'normal' as I have read)
Edit: I may add that primary motivation for VAAPI support is due to enabling AMD hw encoding using the open-source driver.
I agree with your assessment that generic API's need good maturity to compete with specific solutions, like QuickSync (Intel).
Therefor allowing VAAPI in HB (when it's working) in parallel to specific solutions might be desired. Only when VAAPI reaches parity with the individual encoding API one might consider its retirement.
DocMAX commentedon Apr 22, 2018
When will it be done?
sr55 commentedon Apr 22, 2018
@DocMAX There is no ETA and we haven't decided whether to accept this yet, or stick to vendor specific implementations so it'll be some time away.
mirh commentedon Apr 22, 2018
It depends on #1078 to the very least, so wait for that for starters.
sr55 commentedon Jun 29, 2018
Closing in favour of sticking to native support.
Nvenc and quicksync both have support on Linux. AMF looks like it might add support too so we'll pick that up when available.
survivor303 commentedon May 8, 2020
No support from AMD yet.. so perhaps this can be opened again?
userofryzen commentedon May 25, 2020
for me vaapi is mature enough to reopen this.
29 remaining items
jstebbins commentedon Jun 19, 2020
Strange. Can't reproduce that here. I'm running the 1.3.3 release and MediaSDK plugin both installed from flathub.
My CPU specifics for reference
@maximd33 or @agalin89 any ideas?
maximd33 commentedon Jun 19, 2020
@mathstuf can you please try nightly build ?
we had similar issue fixed , #2862
jstebbins commentedon Jun 19, 2020
The nightly build is here:
https://nightly.handbrake.fr/fr.handbrake.ghb-20200614151529-ed54f307f-master-x86_64.flatpak
But this fix should also be in the 1.3.3 release since it was backported here:
7c11f02
sgothel commentedon Jul 23, 2020
@jstebbins I have updated my vaapi work in hw-encoder-vaapi
(as well as general hw-encoder-base and hw-encoder-nvenc - all names of my new branches).
Please feel free to comment, pick, merge ..
The usual TODO: I still have some hardcoded features in vaapi and nvenc,
which I like to have added to the extra-options field.
To enable this for the vaapi/nvenc codecs and have it stored in presets,
I need a little help from you.
Detailed description in the vaapi commit message,
working quite well on a AMD NAVI10 using my mesa-vaapi patch.
1.1) hw-encoder-nvenc https://github.com/sgothel/HandBrake/tree/hw-encoder-nvenc
1.2) hw-encoder-vaapi https://github.com/sgothel/HandBrake/tree/hw-encoder-vaapi
Notable, using vaapi with Handbrake (utilizing the hardcoded soft-frame -> NV12 -> VAAPI)
is faster than ffmpeg commandline: ~150 fps -> ~200 fps
I compared quality differences with x264 ~5Mbit/s and while I couldn't see
any visually really, PSNR and SSIM difference to orig were below 1%.
As usual, great job of all of you working on Handbrake!
I regularly use it, hence my sporadic contributions.
Will help with integration, if intended by your team.
sgothel commentedon Jul 23, 2020
hw-encoder-vaapi commit in question
sgothel@c0fd9ee
sgothel commentedon Jul 23, 2020
The mesa-vaapi patch included is also available here sgothel/mesa@5e10db6
I might need to communicate this one with the mesa and ffmpeg team.
sgothel commentedon Jul 23, 2020
Last one: W/o this mesa-vaapi patch, Matroska can't be stored - mp4 doesn't care.
Hence is usable w/o in a limited format fashion.
mauimauer commentedon Jan 13, 2021
I could get vaapi_h264 going on an AMD Renoir based APU (7400U). HEVC, VP8 and 9 are just logged with "No usable encoding profile found". VCN should support HEVC encoding.
sgothel commentedon Apr 20, 2021
Updated the VAAPI patches.
As usual, some hardcoded parameter exist, as I still wait for UI support
to add additional encoder parameter.
Perhaps one day this gets merged ;-)
I just use this branch for encoding jobs, leaving the CPU cool.
Nice TODO: Test on weak platforms but with VAAPI hw encoder.
@sr55 @jstebbins .. FYI
+++
Note on Mesa: Works with latest git master, haven't checked
in which mesa release the following patches were added:
file: src/gallium/frontends/va/config.c
Needs:
commit 245f619411b5f9b10a11f0c68645f5eae0586d85
Author: Thong Thai [email protected]
Date: Thu Mar 12 10:06:52 2020 -0400
commit 9a4daac0bbf8233f7f1fe5a65aef882f13dccd2e
Author: Thong Thai [email protected]
Date: Tue Jun 2 09:27:07 2020 -0400
.. and perhaps (maybe not):
Author: Thong Thai [email protected]
Date: Fri Feb 12 13:42:42 2021 -0500
RAMChYLD commentedon Jul 6, 2021
Please reopen. There are several problems with the AMD proprietary drivers:
They only work on Ubuntu LTS, RHEL or SLES- enterprise distros. Ubuntu aside, Last I checked SLES and RHEL are NOT free and CANNOT be legally downloaded by most people (only trial is available for SLES, RHEL meanwhile is blocked behind a paywall). The Ubuntu version is fine-tuned for Ubuntu LTS. Trying to install on a non-LTS version of Ubuntu will make very bad things happen (trust me, I've broke a Ubuntu system by installing the proprietary driver on a non-LTS Ubuntu. Black screen and lock up, change VT to get a text based terminal stopped working).
Continuing on the fact above, you cannot use proprietary drivers if you run Arch, Sabayon, Gentoo, etc.
The performance are subpar for gaming. Increased stuttering and lower frame rates have been observed.
sgothel commentedon Jul 22, 2021
From time to time I merge and update my branches, saving some CPU power when I need to transcode our video archive. However, I would love to see this merger but looks like this is the bottom of the priority.
Next update from my side with Debian Bullseye, hopefully the Mesa3D patches are all included in the distribution by then.
https://github.com/sgothel/HandBrake/branches
and
https://jausoft.com/cgit/HandBrake.git/refs/heads
userofryzen commentedon Jul 23, 2021
Keksimus69 commentedon Sep 25, 2022
It's kinda ridiculous to only support proprietary drivers on an open source project for users who want to run an open source operating system...
mathew2214 commentedon Sep 26, 2023
over a year later, still no VAAPI support on AMD. handbrake 1.6.1 MESA 22.3