mpv
mpv copied to clipboard
VAAPI hardware encoders are not supported when transcoding
Important Information
Provide following Information:
- mpv version:
mpv 0.34.0-386-g284fecc0bd built on Wed Jul 27 20:06:56 UTC 2022 - Linux Distribution and Version:
Ubuntu 22.04.1 LTS, kernel 5.19.0-051900-generic - Source of the mpv binary:
https://ppa.launchpadcontent.net/savoury1/mpv/ubuntu - GPU driver and version:
vainfo: Driver version: Mesa Gallium driver 22.1.5 for AMD Radeon RX 6900 XT (sienna_cichlid, LLVM 13.0.1, DRM 3.47, 5.19.0-051900-generic)
Reproduction steps
Run mpv --profile=gpu-hq --vaapi-device=/dev/dri/renderD128 input.mkv -vf=format=nv12,hwupload -ovc=hevc_vaapi -o=output.mkv
Expected behavior
mpv should encode to output.mkv using hevc_vaapi
Actual behavior
Error occurs.
Log file
https://pastebin.com/XXw81ctd
Extra information
Running ffmpeg like so works: ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i input.mkv -vf format=nv12,hwupload -c:v hevc_vaapi output.mkv
Also using mpv --hwdec=vaapi works, it's just the encoding with -ovc=hevc_vaapi that doesn't.
I've tried installing Ubuntu 20.04, 22.04, Debian 11 and none work. I've also tried with both my AMD 6900XT and with Intel iGPU, and neither work.
Why would you wan to encode with mpv rather than ffmpeg?
You're also pointlessly trying to download the frames to system memory instead of passing them directly from the decoder to the encoder on the GPU side.
While I question why you'd do it this way, you'll definitely need it to do hardware decoding in mpv (--hwdec=vaapi) to have any chance of this working.
mpv doesn't support the hardware vaapi encoders when transcoding because it lacks the -init_hw_device or equivalent options that FFmpeg has. You'll either have to use ffmpeg, or use a software encoder like libx264.
Why would you wan to encode with mpv rather than ffmpeg?
I require the --glsl-shaders feature of mpv
The command I gave is just an example of what works in ffmpeg vs what doesn't work in mpv
The actual command I run is a lot more complicated and longer
mpv doesn't support the hardware vaapi encoders when transcoding because it lacks the
-init_hw_deviceor equivalent options that FFmpeg has. You'll either have to use ffmpeg, or use a software encoder like libx264.
Ah, yes I noticed the lack of those specific arguments and was hoping mpv had some alternative libx264 and libx265 do work, they're just significantly slower so I'd prefer to use hardware encoding
Why would you wan to encode with mpv rather than
ffmpeg?
its easier compile mpv with support for vapoursynth and glsl shaders than to recompile ffmpeg for it.
mpv doesn't support the hardware vaapi encoders when transcoding because it lacks the
-init_hw_deviceor equivalent options that FFmpeg has. You'll either have to use ffmpeg, or use a software encoder like libx264.
will mpv ever add support for it?
@thebombzen if it's not supported then why would SVP add it as an option? I have been hitting my head hard to make it work, now I see it was not me who was wrong.
@lavilao @FarisR99 You people do realize that ffmpeg does have glsl shader compatibility?
libplacebo has been a thing in ffmpeg for a while now.
@BlueSwordM glsl yes, vapoursynth no. Edit:while I remember have seen a discussion about this, I can't find the libplacebo options now, what is it?
Even though you didn't use mpv, you could make a transcoding with mpv shaders.
- Here is the ins of libplacebo filter in ffmpeg. (Example https://github.com/mpv-player/mpv/issues/9589#issuecomment-1001067764)
- Or using vs-placebo plugin in vapoursynth.
ffmpeg has a libplacebo filter as linked above, and while FFmpeg technically supports vapoursynth scripts, it's much easier to just pipe it:
vspipe script.vpy --y4m - | ffmpeg -i - -c:v ...
@thebombzen thanks, did not knew You could Pipe it. @hooke007 Thats the discussion! Although it gives me an error saying failed to set value vulkan for option init_hw_device cannot allocate memory
@lavilao @FarisR99 You people do realize that ffmpeg does have glsl shader compatibility?
libplacebo has been a thing in ffmpeg for a while now.
@BlueSwordM I'm aware libplacebo exists, and have of course attempted to use it - however in my experience with it, I've been completely unsuccessful trying various different methods of using it. Sometimes errors with "filter conversions", one command works but doesn't apply any filter even though libplacebo is specified, it's all a bit of a mess.
I like mpv because it makes things far easier to work with, however as stated in the original issue, I'm unable to use my AMD GPU to transcode and have to resort to libx264 which is significantly slower.
To everyone else, thanks for the suggestions - I'm aware of a lot of alternatives and have attempted some of them, but ran into issues. In the end, I'll just purchase a cheap 30 series card for NVENC which "just works".
I think it's pretty safe to say that we won't be adding hardware encoders to mpv.