master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.4k stars 147 forks source link

[Q] Hardware accel for decoding #833

Open barolo opened 1 month ago

barolo commented 1 month ago

Is it possible to insert something like this into av1an chain? ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i ./input.mkv -vf 'scale_vaapi=w=1280:h=720,hwdownload,format=p010le' this gives me three times the fps that I get from av1an [with same svt-av1 config]

gitoss commented 2 weeks ago

The solution would be for av1an to add another param like abav1's "--enc-input" which is placed before ffmpeg's -i. For example, with ab1av1 I'm using '--enc-input hwaccel=d3d11va' which transforms into a '-hwaccel d3d11va' ffmpeg param before -i

This probably would be easy enough to implement, and would offload work to the gpu - so a big +1 for this feature request :-)

Edit: I don't know how/if hw decoding scales with a lot of parallel workers...

barolo commented 2 weeks ago

The thing is, i just want the decoder part, hw encoder would be nice but my current gpus don't have it so...

gitoss commented 2 weeks ago

The thing is, i just want the decoder part, hw encoder would be nice but my current gpus don't have it so...

It would have to be enabled for each possible --chunk-method ...

barolo commented 2 weeks ago

@gitoss Where should I put it in the case of lsmash? Vaporsynth stuff is totally alien to me.

gitoss commented 2 weeks ago

@gitoss Where should I put it in the case of lsmash? Vaporsynth stuff is totally alien to me.

My guess: To be able to work without split files (i.e. direct lsmash, bestsource or ffms2 mode) the change has to be somewhere the av1an source - I have no idea where, never bothered to learn Python or look at the py files.

Or you could load the video through a bare bones Vapoursynth script, enabling hw decoding in the respective line in the vpy file (sample w/o hw decoding param).

from vapoursynth import core
clip = core.bs.VideoSource(source='video.mkv')
clip.set_output()
barolo commented 2 weeks ago

@gitoss Where should I put it in the case of lsmash? Vaporsynth stuff is totally alien to me.

My guess: To be able to work without split files (i.e. direct lsmash, bestsource or ffms2 mode) the change has to be somewhere the av1an source - I have no idea where, never bothered to learn Python or look at the py files.

Or you could load the video through a bare bones Vapoursynth script, enabling hw decoding in the respective line in the vpy file (sample w/o hw decoding param).

from vapoursynth import core
clip = core.bs.VideoSource(source='video.mkv')
clip.set_output()

Av1an uses Rust doesn't it? I might be able to do it. We'll see.