This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

NVEnc Preview
#26
Works fine here,...
import vapoursynth as vs
from vapoursynth import core
import subprocess
import ctypes

NVEnc = r'F:\Hybrid\64bit\NVEncC.exe'
ffmpeg= r'F:\Hybrid\64bit\ffmpeg.exe'
# Loading Plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll") # L-SMASH Source is only usable for mp4 and mov files
source_path=r"C:/Users/Selur/Desktop/TestSubs-1.mp4" # current color space: YUV420P8, bit depth: 8, resolution: 720x300, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive, Note storage resolution is 720x304
source_path=r'G:\TestClips&Co\test.avi' # current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
source_path="C:/Users/Selur/Desktop/TestVideo.mp4"

clip = core.lsmas.LWLibavSource(source=source_path, format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
clip = clip.resize.Bicubic(format=vs.YUV420P16)
w = clip.width
h = clip.height
bitdepth=16
Ysize  = w * h * bitdepth // 8
Usize = w * h//4 * bitdepth // 8
Vsize = w * h//4 * bitdepth // 8
frame_len = Ysize + Usize + Vsize #YUV420

command = [NVEnc,
                 '--avhw',
                 '--input "'+source_path+'" '
                 '-c raw',
                 '--output-res '+str(w)+'x'+str(h),
                 '--output-csp yuv420p',
                 '--output-depth '+str(bitdepth),
                 '--output-format raw',                
                 '--output -',          
             ]
command = [ ffmpeg, '-i', source_path,'-vcodec', 'rawvideo', '-pix_fmt', 'yuv420p16',  '-f', 'rawvideo', '-']            
command = ' '.join(command)

core.log_message(2,command)

pipe = subprocess.Popen(command, stdout = subprocess.PIPE, bufsize=frame_len)

def load_frame(n,f):
    try:
        vs_frame = f.copy()
        for i, size in enumerate([Ysize, Usize, Vsize]):
            ctypes.memmove(vs_frame.get_write_ptr(i), pipe.stdout.read(size),  size)
        pipe.stdout.flush()
    except Exception as e:
        raise ValueError(repr(e))    
    return vs_frame

try:
    clip = core.std.ModifyFrame(clip, clip, load_frame)
except ValueError as e:
    pipe.terminate()
    print(e)

clip.set_output()
(used yuv420p16 in the example)
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
NVEnc Preview - by Dan64 - 01.10.2023, 13:31
RE: NVEnc Preview - by humanoid86 - 01.10.2023, 13:55
RE: NVEnc Preview - by Selur - 01.10.2023, 13:56
RE: NVEnc Preview - by Dan64 - 01.10.2023, 14:26
RE: NVEnc Preview - by Selur - 01.10.2023, 14:28
RE: NVEnc Preview - by Dan64 - 01.10.2023, 14:54
RE: NVEnc Preview - by Selur - 01.10.2023, 15:13
RE: NVEnc Preview - by Dan64 - 01.10.2023, 16:56
RE: NVEnc Preview - by Selur - 01.10.2023, 17:24
RE: NVEnc Preview - by Dan64 - 01.10.2023, 18:19
RE: NVEnc Preview - by Selur - 01.10.2023, 18:22
RE: NVEnc Preview - by Dan64 - 05.10.2023, 17:47
RE: NVEnc Preview - by Selur - 05.10.2023, 17:53
RE: NVEnc Preview - by Dan64 - 07.10.2023, 10:55
RE: NVEnc Preview - by Dan64 - 07.10.2023, 21:16
RE: NVEnc Preview - by Selur - 08.10.2023, 08:08
RE: NVEnc Preview - by Dan64 - 08.10.2023, 09:31
RE: NVEnc Preview - by Selur - 08.10.2023, 09:40
RE: NVEnc Preview - by Dan64 - 08.10.2023, 09:54
RE: NVEnc Preview - by Selur - 08.10.2023, 09:56
RE: NVEnc Preview - by Dan64 - 08.10.2023, 10:42
RE: NVEnc Preview - by Selur - 08.10.2023, 10:50
RE: NVEnc Preview - by Dan64 - 08.10.2023, 10:58
RE: NVEnc Preview - by Selur - 08.10.2023, 11:06
RE: NVEnc Preview - by Dan64 - 08.10.2023, 13:37
RE: NVEnc Preview - by Selur - 08.10.2023, 13:42
RE: NVEnc Preview - by Dan64 - 08.10.2023, 15:12
RE: NVEnc Preview - by Selur - 08.10.2023, 15:24
RE: NVEnc Preview - by Dan64 - 08.10.2023, 15:52
RE: NVEnc Preview - by Selur - 08.10.2023, 16:04
RE: NVEnc Preview - by Dan64 - 08.10.2023, 16:13
RE: NVEnc Preview - by Selur - 08.10.2023, 16:19
RE: NVEnc Preview - by Dan64 - 08.10.2023, 16:33
RE: NVEnc Preview - by Dan64 - 08.10.2023, 19:09
RE: NVEnc Preview - by Selur - 08.10.2023, 19:29
RE: NVEnc Preview - by Dan64 - 09.10.2023, 19:44
RE: NVEnc Preview - by Selur - 09.10.2023, 19:51
RE: NVEnc Preview - by Dan64 - 09.10.2023, 21:12

Forum Jump:


Users browsing this thread: 2 Guest(s)