rigaya / NVEnc

NVENCによる高速エンコードの性能実験
https://rigaya34589.blog.fc2.com/blog-category-17.html
Other
1.1k stars 114 forks source link

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

Closed dan64 closed 5 months ago

dan64 commented 5 months ago

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.

rigaya commented 5 months ago

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.

agressiv commented 5 months ago

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

dan64 commented 5 months ago

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 commented 5 months ago

@rigaya

Dan

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

Dendraspis commented 5 months ago

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.

rigaya commented 5 months ago

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.

agressiv commented 5 months ago

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.