NVEnc icon indicating copy to clipboard operation
NVEnc copied to clipboard

Using option --vpy to directly feed a Vapoursynth script is much slower than using vspipe.

Open dan64 opened this issue 1 year ago • 7 comments

Using option --vpy to directly feed a Vapoursynth script is much slower than using vspipe.

On my tests

NVEncC.exe --vpy -i test_script.vpy --fps 23.976 --codec h265 --profile main10 --level auto --tier high --sar 1:1 --output-depth 10 --vbr 0 --vbr-quality 27.00 --aq --aq-strength 1 --aq-temporal --gop-len 0 --ref 3 --nonrefp --bframes 3 --bref-mode each --mv-precision Q-pel --preset default --colorrange limited --colormatrix bt709 --cuda-schedule sync --psnr --ssim --output test.265

the movie is encoded in double time respect to vspipe

vspipe.exe "test_script.vpy" - -c y4m | NVEncC.exe --y4m -i - --fps 23.976 --codec h265 --profile main10 --level auto --tier high --sar 1:1 --output-depth 10 --vbr 0 --vbr-quality 27.00 --aq --aq-strength 1 --aq-temporal --gop-len 0 --ref 3 --nonrefp --bframes 3 --bref-mode each --mv-precision Q-pel --preset default --colorrange limited --colormatrix bt709 --cuda-schedule sync --psnr --ssim --output test.265

such a difference is not justified, why does it happen?

P.S. Probably you should open the script using more threads.

dan64 avatar Jun 08 '24 19:06 dan64

why does it happen?

I'm not sure about this, and I have idea to solve. Threading is done on the vapoursynth side, and not on the application side.

rigaya avatar Jun 11 '24 10:06 rigaya

Try using --vpy-mt. It's much faster for me.

agressiv avatar Jun 27 '24 01:06 agressiv

the parameter "--vpy-mt" is available only in QSVenc/VCEEnc.

EDIT: actually the parameter "--vpy-mt" is available also for NVEnc but is not included in the documentation. With this parameter the speed increase significantly and the problem is solved on my side.

Thanks

dan64 avatar Jun 27 '24 17:06 dan64

@rigaya

  • which is the difference between "--vpy" and "--vpy-mt" ?
  • could happen that will be scripts that will work only with "--vpy" ?

Dan

P.S. the parameter "--vpy-mt" should be added in the documentation regarding NVEnc options

dan64 avatar Jun 28 '24 08:06 dan64

I checked the code pretty quick and according to this code line VapourSynth should be run only with one thread as long as --vpy-mt is not used: https://github.com/rigaya/NVEnc/blob/d81bf9c6cc70ff59565d3a3878736b48ba157609/NVEncCore/rgy_input_vpy.cpp#L193

...whereas AviSynth is run without limitations: https://github.com/rigaya/NVEnc/blob/d81bf9c6cc70ff59565d3a3878736b48ba157609/NVEncCore/rgy_input_avi.cpp#L61

As VapourSynth itself uses multi-threading, I personally would prefer to have a --vpy parameter that works like --vpy-mt does right now - meaning using multi-threading. In case there is a need for a single-threaded run, I would suggest using --vpy-st (Single Thread). Of course all over the 3 encoders.

If it's not intended to change that, the docs should be extended to make the differences more obvious.

Dendraspis avatar Jun 28 '24 13:06 Dendraspis

Actually I forgot most of these implementations, as I've written so many years ago. I think it was that although --vpy-mt could enhance vapoursynth multi threading, there were cases that --vpy-mt smoehow failed, and I decided not to go into that further (and I will not). So --vpy is made default instead of --vpy-mt, and --vpy-mt not written in docs explicitly.

Actually it seems that I failed to remove --vpy-mt from QSVEnc docs.

rigaya avatar Jun 28 '24 13:06 rigaya

For what it's worth, I've never had a problem with --vpy-mt, even with a ton of plugins, granted I haven't used it THAT much though.

agressiv avatar Jun 29 '24 04:06 agressiv