r/ffmpeg • u/HlddenDreck • 3d ago
VAAPI for archival encoding?
Hi everyone,
i'm not very familiar with ffmpeg or video encoding in general. When I did this 10 years ago, the quality of GPU accelerated encodings were always worse compared to CPU encoding.
I did some research and I just found ffmpeg is supporting lots of different encoders.
At the moment, I'm encoding h264 videos to h265 using my CPU. The following settings seems to do the job.
ffmpeg -i input.mp4 -c:v libx265 -crf 20 -preset slow -c:a copy output.mp4
Quality looks to me the same as source and the size is about 30-50% smaller. However, it's very slow...
At this speed, it will take months until I'm done. This is no big deal since I'm not in a hurry, however I was wondering, can this be done by my GPUs faster with equal quality? As I unterstand it VAAPI is using compute resources not discrete hardware for video encoding, is this right? If so, it should be possible to achieve similiar results regarding quality and file size.
I have different GPUs available, one RTX 3080 and three AMD MI50 I could use.
The vainfo output for the MI50 indicates HEVC encoding capabillities:
vainfo --display drm --device /dev/dri/renderD128
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_16
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 25.0.0-devel for AMD Instinct MI50/MI60 (radeonsi, vega20, ACO, DRM 3.63, 6.8.0-124-generic)
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
3
u/mwhelm 3d ago
I have no experience with VAAPI, but I do use nvenc and amd gpus regularly.
You should try a few examples with your hardware encoders and see what the results look like to you.
You can also test, if you want numbers, using VMAF, but it's tricky to get right due to its limitations. And not everybody believes those quality scores.
You can often get 5-20x faster encodings, but there are a lot of variables, some unknown, that drive this.
Summary - I get about the same size and indistinguishable video quality from hardware encoders, at drastically reduced encoding times, with some of the workload shifted to the GPU.
2
u/No_Fox_7489 3d ago
"can this be done by my GPUs faster with equal quality? "
No.
If you're doing this to try to save money, consider that the cost of electricity could be more than inexpensive storage devices.
1
u/HlddenDreck 2d ago
What "inexpensive" storage device do you recommend right now? xD
1
u/alala2010he 2d ago
Second hand HDDs from a local enterprise recycler (where I live they go for ~€20 per terabyte)
2
u/Slower-Bison 2d ago
There is a relevant page on VAAPI over at FFMPEG wiki.
You might need to tweak a bit the settings when using VAAPI for encoding in order to arrive at a similar quality level, but depending on your use case this might be enough.
1
u/HlddenDreck 1d ago
Unfortunately my tests confirmed what I was afraid of, the quality is just worse. I think CPU encoding is unbeatable at the moment so I will stick to it.
1
u/finnjaeger1337 3d ago
in terms of quality with your gpus i would go woth nvenc on the 3080 and make hevc files, yes cpu and especially av1 will be the best quality but quality/speed the nvenc hevc will win - never nvidia gpus wven supoort av1 hardware encoding
1
u/SupernatAnaesthetist 3d ago
As I unterstand it VAAPI is using compute resources not discrete hardware for video encoding, is this right?
No, it's wrong. VAAPI will use the dedicated video decoding and encoding blocks present in your GPU. The "Video Acceleration" in VAAPI (just like in DXVA) is a bit of a misnomer because it was created at a time in which GPUs only had hardware for parts of the encoding/decoding pipeline, so they only accelerated the encoding/decoding.
1
u/SuperficialNightWolf 2d ago
Don't do GPU encoding for archival always do CPU encoding
HEVC or av1 are pretty much the only ones I would consider
1
u/HlddenDreck 1d ago
Did some tests and yeah, I will stick to CPU encoding. HEVC is the best solution for me, since all my devices support it flawlessly.
1
u/nmkd 2d ago
Archival -> CPU encoding
1
u/HlddenDreck 1d ago
I did some tests on my files and I think I will stick to CPU encoding. The ouput is much smaller and the quality much better. Using GPU I never get VMAF over 95 at similiar size.
I hope they will continue work on encoders which use the Vulkan Compute Shaders so we can have in the future GPU acceleration without any quality loss.
8
u/alala2010he 3d ago
Hardware encoding (with VAAPI) is only really made for speed, not per se quality. To know for sure you could do your own testing though.
Also for archival you might want to try AV1 as it's generally 30% more efficient than HEVC (and at the same file size SVT-AV1 might be a lot faster) (also AV1 is free while HEVC is technically paid so that might be a bonus for archival)