Selur's Little Message Board

Full Version: NVEncC -vpy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello Selur,

   A lesson learnt from "vs-deoldify" it is that just a simple message raised by the vapoursynth script can break the pipe and stop the encoding.
   In these days where are becoming available strong filters using IA, the probability these kind of problems can happen is becoming more frequent.
   It can happen, like in " vs-codeformer " that the filter was developed for research and is plenty of "print()".
   In this context "vsPipe" is not a suitable tool, because the "pipe" can be broken and nothing can done to recover from this error (not always it is possible to ask to the filter developer to fix the issue, like in "vs-codeformer").
  Since you are not willing to apply the changes that I proposed for "vsViewer" and you don't want to use the vapoursynth enabled version of ffmpeg.
  I'm asking you if you can add the support to "NVEncC -vpy".
  I performed a simple test and it worked.

  To perform the test I followed the folllowing steps:

1) installed the last version of NVEncC64.exe in "Hybrid\64bit\Vapoursynth" (because it need "VSScript.dll")

2) I wrote a simple Vapoursynth script: VideoBW_720p_10bit.vpy

Code:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import site
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'D:/Programs/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="D:/Programs/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# current color space: YUV420P8, bit depth: 8, resolution: 1280x692, fps: 23.976, scanorder: progressive, yuv luminance scale: limited, matrix: 709, transfer: bt.709, primaries: bt.709
clip = core.lsmas.LWLibavSource(source="VideoTest1_720p.mp4", format="YUV420P8", stream_index=0, cache=0, fpsnum=24000, fpsden=1001, prefer_hw=0)
frame = clip.get_frame(0)
# Setting detected color matrix (709).
clip = core.std.SetFrameProps(clip, _Matrix=1)
# Setting color transfer (709), if it is not set.
if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  clip = core.std.SetFrameProps(clip, _Transfer=1)
# Setting color primaries info (to 709), if it is not set.
if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  clip = core.std.SetFrameProps(clip, _Primaries=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 23.976
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# adjusting output color to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
# making sure frame rate is set to 23.976
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
clip.set_output()

3) Execute the following command

Code:
D:\PProjects\vs-deoldify_dev>"D:\Programs\Hybrid\64bit\Vapoursynth\NVEncC64.exe" --vpy -i VideoBW_720p_10bit.vpy --fps 23.976 --sar 1:1 --codec h265 --profile main10 --output-depth 10 --output-res 1280x692 --vbr 0 --vbr-quality 26.0 --aq --aq-strength 1 --output VideoBW_720p_10bit-1.hevc
--------------------------------------------------------------------------------
VideoBW_720p_10bit-1.hevc
--------------------------------------------------------------------------------

NVEncC (x64) 7.42 (r2750) by rigaya, Feb 27 2024 12:48:31 (VC 1929/Win)
OS Version     Windows 10 x64 (19045) [UTF-8]
CPU            Intel Core i9-10900 @ 2.80GHz [TB: 4.92GHz] (10C/20T)
GPU            #0: NVIDIA GeForce RTX 3060 (3584 cores, 1837 MHz)[PCIe3x16][551.23]
NVENC / CUDA   NVENC API 12.1, CUDA 12.4, schedule mode: auto
Input Buffers  CUDA, 20 frames
Input Info     VapourSynth r65(yv12(10bit))->p010 [AVX2], 1280x692, 24000/1001 fps
Vpp Filters    copyHtoD
Output Info    H.265/HEVC main10 @ Level auto
               1280x692p 1:1 23.976fps (24000/1001fps)
Encoder Preset default
Rate Control   VBR
Multipass      none
Bitrate        0 kbps (Max: 11520 kbps)
Target Quality 26.00
Initial QP     I:20  P:23  B:25
QP range       I:0-63  P:0-63  B:0-63
QP Offset      cb:0  cr:0
VBV buf size   auto
Split Enc Mode auto
Lookahead      off
GOP length     240 frames
B frames       3 frames [ref mode: disabled]
Ref frames     3 frames, MultiRef L0:auto L1:auto
AQ             on (spatial, strength 1)
CU max / min   auto / auto
Others         mv:auto

encoded 2594 frames, 820.63 fps, 1358.66 kbps, 17.52 MB
encode time 0:00:03, CPU: 20.3%, GPU: 22.0%, VE: 74.8%, GPUClock: 1888MHz, VEClock: 1655MHz
frame type IDR   11
frame type I     11,  total size  0.35 MB
frame type P    649,  total size  8.53 MB
frame type B   1934,  total size  8.64 MB

  The final file was playable, so I think that the use of NVEncC with the option "-vpy" is worth your attention.
  Please consider the possibility to enable it.

Thanks,
Dan
Quote:Please consider the possibility to enable it.
Thought about it.
  • Avisynth/Vapoursynth filters should not dump stuff to std:cout, the filter should catch the messages and then use Vapourynths log methods to report important stuff.
  • Messages that are not dealt with through Vapoursynths log handling, should indicate a problems and are 'allowed' to break stuff.
  • Not planning to copy the VSScript next to NVEncC or the other way around.
  • Next thing is, folks want the same for Avisynth
-> Won't add it. If you think this is critical to your processing, do not use Hybrid.

Cu Selur
I don't care about Avisynth, in the 21st century, the adoption of IA programs will increase significantly and most of them will be written in python because the libraries most used by IA (i.e. neural networks) are written in python.
It will be also a significant development on IA imaging manipulation, and Vapoursynth, being based on python, will benefit from this development. 
I cannot say the same for Avisynth, which will not be able to benefit from this new development.

Dan
(02.03.2024, 10:06)Selur Wrote: [ -> ]
Quote:Please consider the possibility to enable it.
Thought about it.
  • Not planning to copy the VSScript next to NVEncC or the other way around.
->  Won't add it. If you think this is critical to your processing, do not use Hybrid.

Cu Selur

Hello Selur,

  In the case it could be useful to provide a faster (and more robust) alternative to "vsPipe" when is used NVEnc, recently Rigaya has added the "--vsdir" to support portable VapourSynth installations (like Hybrid): https://github.com/rigaya/NVEnc/releases/tag/7.52

Dan
What makes you think it is faster? Did you test that?
I can understand that, if some filters (wrongly) spam output that can cause issues, but it should not be faster.

Cu Selur

Ps.: I'll think about adding support for it. (requires quite a few changes)
Regarding the release 7.52, it could be useful this post: https://github.com/rigaya/NVEnc/issues/580

Quote:As of version 7.49, 3 new encoding options have been implemented. The options give an excellent result in terms of encoding quality at HEVC/h265. The options are:
Code:
--tune
--tf-level
--lookahead-level

If you want the performance before 7.49, use them like this:
Code:
--tune lowlatency or ultralowlatency
--tf-level 0
--lookahead-level 0

Lower performance is primarily due to --tf-level and --tune uhq. As of version 7.50, the default value of --lookahead-level is 0 and you don't have to explicitly set it.
If you want maximum quality, then use:
Code:
--tune uhq --> only supported by Turing+ architecture.
--tf-level 4
--lookahead-level auto
Removed in 7.51: https://github.com/rigaya/NVEnc/releases/tag/7.51

In 7.51 was added a new denoise filter: "--vpp-nlmeans"

Dan
What about the speed? (see post #5)
I asked Rigaya to add this option: https://github.com/rigaya/NVEnc/issues/564

But then I was busy in writing the coloring filters I had not time to test it.

Dan
Pages: 1 2 3