Log in

View Full Version : Vapoursynth


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 [60] 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

ChaosKing
2nd February 2018, 11:23
I don't think it will work, but there is https://github.com/chikuzen/vsrawsource

Binary: https://forum.doom9.org/showthread.php?t=166075

Maybe ffms can also open raw files!?

monohouse
2nd February 2018, 11:44
he can't I tryed, I will test this one, thank :)

poisondeathray
2nd February 2018, 16:31
he can't I tryed, I will test this one, thank :)

vsrawsource works for me

Maybe problem with your file or script ?

Any error messages ? Post your script

LigH
2nd February 2018, 22:33
No, FFMS2 can't read raw YUV.

VS_Fan
3rd February 2018, 22:12
I remember having troubles some time ago reading raw video streams with vsrawsource. Then I managed to use ffmpeg and ffms2 as a workaround. Based on a limitation specified in ffms2 documentation: “Because of LAVF's demuxer, most raw streams […] will fail to work properly”, I used ffmpeg to generate a new file with the raw video inside an MKV container:
For 420p8 (rawvideo): ffmpeg -f rawvideo -vcodec rawvideo -pixel_format yuv420p -video_size <XXXxYYY> -framerate <num>:<den> -i <input_raw_yuv_420p8_file> -pix_fmt yuv420p -vcodec rawvideo -an <output_raw_yuv_420p8_file>.mkvFor 422p10 (v210): ffmpeg -f v210 -vcodec v210 -pixel_format yuv422p10le -video_size <XXXxYYY> -framerate <num>:<den> -i <input_raw_yuv_422p10_file> -pix_fmt yuv422p10le -vcodec v210 -an <output_raw_yuv_422p10_file>.mkv
After that, I could successfully use .ffms2.Source() to read those raw video streams contained in mkv

Myrsloik
8th February 2018, 11:48
Here's a build with updated zimg (https://www.dropbox.com/s/htfjbr08ldjzf25/VapourSynth-R43-fix1.exe?dl=1) as the only difference. It should fix crash issues on core 2 quad cpus. Everything else is unaffected.

Myrsloik
8th February 2018, 11:51
I remember having troubles some time ago reading raw video streams with vsrawsource. Then I managed to use ffmpeg and ffms2 as a workaround. Based on a limitation specified in ffms2 documentation: “Because of LAVF's demuxer, most raw streams […] will fail to work properly”, I used ffmpeg to generate a new file with the raw video inside an MKV container:
For 420p8 (rawvideo): ...

Raw is mostly in the sense no container AND uncompressed video format without sufficient headers. Basically things where width, height and format aren't stored so you'd need extra arguments to pass it along. By this definition not even y4m is raw.

Selur
8th February 2018, 17:38
@Myrsloik: Any change for a fixed portable 64bit version? :)

feisty2
8th February 2018, 18:04
I just ditched uncompressed raw recently, instead I switched to uncompressed TIFF sequence, it's still uncompressed but saves u from manually specifying the width, height, sample type, endianness and colorspace...

feisty2
8th February 2018, 18:34
something that makes uncompressed TIFF sequence a bit better than y4m is that it's a universal format and supported everywhere, numpy and scipy got native support for TIFF sequence and can convert it to a numpy array or memmap if the sequence is too large, uncompressed raw is also universally supported but like I just said, it requires u to specify a few things and that sucks, and y4m is pretty much unknown and generally not supported in programs other than a few encoding tools...

Myrsloik
8th February 2018, 23:05
@Myrsloik: Any change for a fixed portable 64bit version? :)

Maybe later. Report some more bugs so I'll have to make a full release...

cwk
9th February 2018, 03:27
Have the inpand and expand functions been ported to Vapoursynth? I'm looking to run a dehalo script on linux, so using the Avisynth repair dll is a no go.

WolframRhodium
9th February 2018, 04:26
Have the inpand and expand functions been ported to Vapoursynth? I'm looking to run a dehalo script on linux, so using the Avisynth repair dll is a no go.

inpand:
core.std.Minimum (http://www.vapoursynth.com/doc/functions/minimum_maximum.html#std.Minimum)

expand:
core.std.Maximum (http://www.vapoursynth.com/doc/functions/minimum_maximum.html#std.Maximum)

cwk
9th February 2018, 05:45
Many thanks Wolfram.

MonoS
9th February 2018, 21:35
If i need some quite big buffer (for 4k content about 100mb) in my plugin and don't want to allocate via malloc at every frame and instead allocate at filter instantiation, how can i do it?

TheFluff
9th February 2018, 22:50
If i need some quite big buffer (for 4k content about 100mb) in my plugin and don't want to allocate via malloc at every frame and instead allocate at filter instantiation, how can i do it?
Is the allocation actually slowing you down a lot? Have you benchmarked it?

Myrsloik
9th February 2018, 23:30
If i need some quite big buffer (for 4k content about 100mb) in my plugin and don't want to allocate via malloc at every frame and instead allocate at filter instantiation, how can i do it?

Make it parallelrequests. Allocate it once in the constructor. See if less parallelism even matters?

Selur
10th February 2018, 00:19
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Loading F:\TestClips&Co\files\Test-AC3-5.1.avi using FFMS2
clip = core.ffms2.Source(source="F:/TESTCL~1/files/TEST-A~1.AVI",cachefile="H:/Temp/avi_4a88093b3b83d19d00642a5a96b0af78_41.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Point(clip, matrix_in_s="470bg")
# Making sure input color range is set to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# Loading F:\TestClips&Co\files\Subtitles\Appa 7 Arb done.ass using SubText
clip = core.sub.TextFile(clip=clip, file="F:/TestClips&Co/files/Subtitles/Appa 7 Arb done.ass", fontdir="G:/Hybrid/settings/fonts")
# adjusting output color from: RGB24 to YUV420P10 for x265Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg")
# Output
clip.set_output()
gives me:
Error getting the frame number 0:
Resize error: Resize error 3074: no path between colorspaces (2/2/2 => 5/2/2). May need to specify additional colorspace parameters.

Seems like I'm missing some additional colorspace parameters, but which?

Cu Selur

VS_Fan
10th February 2018, 01:40
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", matrix_in_s="470bg")
edit: or simply:
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10)

Selur
10th February 2018, 06:49
Thanks :)

MonoS
10th February 2018, 17:22
Is the allocation actually slowing you down a lot? Have you benchmarked it?

I can't quantify it precisely, but i guess about 5/10%

Make it parallelrequests. Allocate it once in the constructor. See if less parallelism even matters?

With ParallelRequests it's about 20% slower.

Stephen R. Savage
11th February 2018, 00:30
You can store the buffer per-thread. Allocate the buffer on first use.


std::map<std::thread::id, std::shared_ptr<void>> per_thread_buffer;

/* ... */ get_frame(/* ... */)
{
void *buf = per_thread_buffer[std::this_thread::get_id()].get();
// ...
}


You can also use VSAPI::newVideoFrame to allocate memory. The allocation is cached in the frame buffer pool.


/* ... */ get_frame(/* ... */, VSCore *core, VSAPI *vsapi)
{
const int buffer_size = /* ... */;
VSFrameRef *buf_frame = vsapi->newVideoFrame(vsapi->getFormatPreset(pfGray8, core), buffer_size, 1, nullptr, core);
void *buf = vsapi->getReadPtr(buf_frame, 0);
// ...
vsapi->freeFrame(buf_frame);
}

MonoS
11th February 2018, 11:49
You can store the buffer per-thread. Allocate the buffer on first use.


std::map<std::thread::id, std::shared_ptr<void>> per_thread_buffer;

/* ... */ get_frame(/* ... */)
{
void *buf = per_thread_buffer[std::this_thread::get_id()].get();
// ...
}


You can also use VSAPI::newVideoFrame to allocate memory. The allocation is cached in the frame buffer pool.


/* ... */ get_frame(/* ... */, VSCore *core, VSAPI *vsapi)
{
const int buffer_size = /* ... */;
VSFrameRef *buf_frame = vsapi->newVideoFrame(vsapi->getFormatPreset(pfGray8, core), buffer_size, 1, nullptr, core);
void *buf = vsapi->getReadPtr(buf_frame, 0);
// ...
vsapi->freeFrame(buf_frame);
}


i tried the first solution and i got about 5% of performance, thanks :D

kriNon
28th February 2018, 15:51
Could someone please explain how to get the OCR plugin working? Supposedly it's meant to be an included plugin, however my installation doesn't have any corresponding dll file. I've taken a look at five or so of the latest vapoursynth releases on github and none of them have included the dll for the ocr plugin.

Selur
28th February 2018, 17:37
1st time I hear of an ocr plugin for Vapoursynth,... :)

kriNon
1st March 2018, 02:15
Yeah, supposedly it exists according to: www.vapoursynth.com/doc/plugins/ocr.html
Can't find any documentation on getting it setup and working though as it doesn't seem to come with vapoursynth from what I can tell

Myrsloik
1st March 2018, 11:33
Yeah, supposedly it exists according to: www.vapoursynth.com/doc/plugins/ocr.html
Can't find any documentation on getting it setup and working though as it doesn't seem to come with vapoursynth from what I can tell

Nobody ever bothered to make a windows compile of it. That's mostly the problem. I'll poke someone and include it the next release.

Hrxn
14th March 2018, 01:10
Short question regarding the documentation:

From the Windows Portable Instructions

Simply decompress the portable VapourSynth archive into the Python dir and overwrite all existing files. Done.

You can also use the VapourSynth Editor by decompressing it into the same directory.

Extracting VapourSynth64-Portable-Rxx.7z to "Python dir", as in the directory of the Python system installation?

The usual default is XXXX\AppData\Local\Programs\Python\Python36

.. and the VapourSynth Editor should be extracted into this directory as well?

There isn't another way to do this? Without tampering with my Python install dir?

Selur
14th March 2018, 01:23
I use a portable Vapoursynth and Pyhton in Hybrid.
I downloaded the portable Vapoursynth and extracted the portable Python into the Vapoursynth folder, into which I also extracted vsedit, works all fine.
If you got a system wide Python installed no moving of the portable version or vsedit is required iirc.

Cu Selur

ChaosKing
18th March 2018, 19:57
I wrote a small "vs plugin loading checker" script and got some errors...
What does "No entry point found" mean exactly? CombMask should be a vs dll.
Error 193 means it's a 32Bit dll, correct?

Is it possible to not autoload all plugins when using get_core()?

#######################################
VapourSynth Video Processing Library
Copyright (c) 2012-2018 Fredrik Mellbin
Core R43
API R3.5
Options: -

#######################################
checking dlls in E:\PortableApps\VapourSynth\plugins64
#######################################
Failed to load E:\PortableApps\VapourSynth\plugins64\bilateralGPU.dll. GetLastError() returned 126. A DLL dependency is probably missing.
No entry point found in E:\PortableApps\VapourSynth\plugins64\CombMask.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\cudart64_80.dll
Failed to load E:\PortableApps\VapourSynth\plugins64\externalfilters.dll. GetLastError() returned 193.
No entry point found in E:\PortableApps\VapourSynth\plugins64\libfftw3-3.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\libfftw3f-3.dll
Failed to load E:\PortableApps\VapourSynth\plugins64\libIlmImf.dll. GetLastError() returned 126. A DLL dependency is probably missing.
No entry point found in E:\PortableApps\VapourSynth\plugins64\libiomp5md.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\libmfxsw64.dll
Plugin load failed, namespace focus already populated (E:\PortableApps\VapourSynth\plugins64\libtemporalsoften.dll)
No entry point found in E:\PortableApps\VapourSynth\plugins64\ReduceFlicker.dll
Failed to load E:\PortableApps\VapourSynth\plugins64\scenechange.dll. GetLastError() returned 193.
No entry point found in E:\PortableApps\VapourSynth\plugins64\svml_dispmd.dll
Failed to load E:\PortableApps\VapourSynth\plugins64\tc2cfr.dll. GetLastError() returned 193.
Failed to load E:\PortableApps\VapourSynth\plugins64\temporalsoften2.dll. GetLastError() returned 193.
No entry point found in E:\PortableApps\VapourSynth\plugins64\w2xc.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\XySubFilter.dll
#######################################
Found 103 dlls. Errors: 17


import sys, os, glob
import vapoursynth as vs


def print_version(core):
vs_version = core.version()
print('#######################################')
print(vs_version)
print('#######################################')


def main(argv):
if(len(sys.argv) > 1):
path = argv[1]
else:
exit("\n\rUsage: vs_plugin_check.py <path-to-vapoursynth-plugins-folder>\n\r")

core = vs.get_core()
print_version(core)

plugin_dir = glob.glob(path + '/*.dll')

print("checking dlls in", path)
print('#######################################')

error_count = 0
for dll in plugin_dir:
cnt += 1
try:
core.std.LoadPlugin(path=dll)
except Exception as e:
if "already loaded" not in str(e):
error_count += 1
print(e)

print('#######################################')
print("Found", len(plugin_dir), "dlls. Errors:", error_count)
print()


if __name__ == "__main__":
main(sys.argv)

Myrsloik
18th March 2018, 20:24
I wrote a small "vs plugin loading checker" script and got some errors...
What does "No entry point found" mean exactly? CombMask should be a vs dll.
Error 193 means it's a 32Bit dll, correct?

Is it possible to not autoload all plugins when using get_core()?


...

No entry point simply means the dll doesn't export a function named VapourSynthPluginInit (or it's stdcall mangled equivalent). It's simply not a VS plugin then. Note that unlike avisynth the entry point stuff has never changed...

Error code 193 can be found here
here (https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx). It's vague but probably corrupt file or not the correct bitness.

Autoloading will always be on. Don't put stuff in the folder if you don't want to use it. If you don't use it I'll taunt you and call you smelly.

ChaosKing
18th March 2018, 22:00
No entry point simply means the dll doesn't export a function named VapourSynthPluginInit (or it's stdcall mangled equivalent). It's simply not a VS plugin then. Note that unlike avisynth the entry point stuff has never changed...

Error code 193 can be found here
here (https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx). It's vague but probably corrupt file or not the correct bitness.

Autoloading will always be on. Don't put stuff in the folder if you don't want to use it. If you don't use it I'll taunt you and call you smelly.

After a long and thorough shower I pushed this script with some updates to github in case some one needs it: https://github.com/theChaosCoder/vapoursynth-plugin-check

#######################################
checking dlls in E:\PortableApps\VapourSynth\plugins64
#######################################
Errors:
-------
Failed to load E:\PortableApps\VapourSynth\plugins64\bilateralGPU.dll. GetLastError() returned 126. A DLL dependency is probably missing.
Failed to load E:\PortableApps\VapourSynth\plugins64\libIlmImf.dll. GetLastError() returned 126. A DLL dependency is probably missing.
Plugin load failed, namespace focus already populated (E:\PortableApps\VapourSynth\plugins64\libtemporalsoften.dll)

Errors: Not a VS-Plugin
-------
No entry point found in E:\PortableApps\VapourSynth\plugins64\CombMask.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\ReduceFlicker.dll
No entry point found in E:\PortableApps\VapourSynth\plugins64\XySubFilter.dll

Errors: incorrect bitness (32bit instead of 64bit) or corrupt file.
-------
Failed to load E:\PortableApps\VapourSynth\plugins64\externalfilters.dll. GetLastError() returned 193.
Failed to load E:\PortableApps\VapourSynth\plugins64\scenechange.dll. GetLastError() returned 193.
Failed to load E:\PortableApps\VapourSynth\plugins64\tc2cfr.dll. GetLastError() returned 193.
Failed to load E:\PortableApps\VapourSynth\plugins64\temporalsoften2.dll. GetLastError() returned 193.

Notices:
-------
cudart64_80.dll some dll for CUDA GPU stuff
libfftw3-3.dll is a dependency by fft3dfilter or mvtools-sf
libfftw3f-3.dll is a dependency by fft3dfilter or mvtools-sf
libiomp5md.dll is part of the Waifu2x-w2xc filter
libmfxsw64.dll is part of the DGMVCSourceVS filter
svml_dispmd.dll is part of the Waifu2x-w2xc filter
w2xc.dll is part of the Waifu2x-w2xc filter
#######################################
Found 103 dlls. Errors: 10 Notices: 7

Myrsloik
2nd April 2018, 21:01
R44-test1 (https://www.dropbox.com/s/ytt1gonb15lh9cq/VapourSynth-R44-test1.exe?dl=1)

Basically the only notable change is largepage support. Try it and see if it makes memory allocation when processing 4k material faster. To better compare it can be disabled by setting the environment variable VS_NO_LARGE_PAGES. Have fun...

hydra3333
3rd April 2018, 10:50
Thank you.

Selur
7th April 2018, 05:35
Small question, how can I check whether either: 'core.nnedi3.nnedi3' or 'core.znedi3.nnedi3' is available.
Background: I want to adjust a bunch of scripts (like havsfunc.py) to only use 'core.znedi3.nnedi3' in case it's available and use 'core.nnedi3.nnedi3' otherwise, since the OS X Installer currently has no znedi3 (same for eedi3m).

Cu Selur

Selur
7th April 2018, 05:58
Thanks! :)

Selur
7th April 2018, 06:27
Thanks.

VS_Fan
7th April 2018, 07:27
Basically the only notable change is largepage support.You could be interested in this possible windows 10 system bug (https://sourceforge.net/p/sevenzip/discussion/45797/thread/e730c709/), reported by 7-Zip author and some 7-Zip users, causing system crashes and corruption when using large memory pages

Myrsloik
12th April 2018, 21:39
I'm disappointed, nobody benchmarked it? Do I really have to produce my own benchmarketing material?

Btw, the bug seems to be fixed in the spring creator's update so hopefully by the time R44 is released it won't really be a problem. I think the only other real improvements for R44 will be further tweaks to the memory pool. There have been surprisingly few bugs reported so far, only the poor core 2 quad users don't like R43...

LigH
12th April 2018, 22:57
benchmarketing

Freud likes that. :p

LigH
13th April 2018, 13:56
The only other application I remember having support for large pages is 7-zip.

Selur
15th April 2018, 06:25
So enabling large page support is a bad thing atm. :)

VS_Fan
15th April 2018, 19:35
Shouldn't Linux, macOS and Windows 10 v18.03 users be safe testing with Large Memory Pages? It would be nice to have any benchmarks from them.

Igor Pavlov (developer of 7-zip) posted (https://sourceforge.net/p/sevenzip/discussion/45797/thread/e730c709/#b240/0211) his findings and thoughts some 5 days ago

Myrsloik
15th April 2018, 19:36
Shouldn't Linux, macOS and Windows 10 v18.03 users be safe testing with Large Memory Pages? It would be nice to have any benchmarks from them.

Igor Pavlov (developer of 7-zip) posted (https://sourceforge.net/p/sevenzip/discussion/45797/thread/e730c709/#b240/0211) his findings and thoughts some 5 days ago

It's safe on all windows 10 versions. There's a workaround for the bug. Obviously D9 didn't bother to actually try it but instead went off and made stuff up...

VS_Fan
16th April 2018, 08:51
I’m on laptop with an intel core i5 4gen, 8GB RAM and windows 10 home edition (v18.03 = 10.0.16299.371), so no group policy editor for me. So I tried running vspipe in a command prompt with administrator rights to get LP working.

This are the results for the same vpy script provided by HolyWu: (vspipe.exe test.vpy .)

Vapoursynth R43: (No LP)
Output 500 frames in 37.62 seconds (13.29 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES set:
Output 500 frames in 40.75 seconds (12.27 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set:
Output 500 frames in 37.51 seconds (13.33 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set: (on an administrator command prompt)
Windows VirtualAlloc bug detected: page still mapped
Output 500 frames in 39.67 seconds (12.60 fps)

The time variations could be related to the antivirus scanning my external USB disk in the background

Myrsloik
16th April 2018, 09:21
I’m on laptop with an intel core i5 4gen, 8GB RAM and windows 10 home edition (v18.03 = 10.0.16299.371), so no group policy editor for me. So I tried running vspipe in a command prompt with administrator rights to get LP working.

This are the results for the same vpy script provided by HolyWu: (vspipe.exe test.vpy .)

Vapoursynth R43: (No LP)
Output 500 frames in 37.62 seconds (13.29 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES set:
Output 500 frames in 40.75 seconds (12.27 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set:
Output 500 frames in 37.51 seconds (13.33 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set: (on an administrator command prompt)
Windows VirtualAlloc bug detected: page still mapped
Output 500 frames in 39.67 seconds (12.60 fps)

The time variations could be related to the antivirus scanning my external USB disk in the background

I think your background tasks have a bigger effect than large pages at its best.

lansing
17th April 2018, 04:47
I find the wording of "VS_NO_LARGE_PAGES set/not set" confusing. I have to rethink a few times every time I read it because of the double negative.

foxyshadis
17th April 2018, 04:52
I’m on laptop with an intel core i5 4gen, 8GB RAM and windows 10 home edition (v18.03 = 10.0.16299.371), so no group policy editor for me. So I tried running vspipe in a command prompt with administrator rights to get LP working.

This are the results for the same vpy script provided by HolyWu: (vspipe.exe test.vpy .)

Vapoursynth R43: (No LP)
Output 500 frames in 37.62 seconds (13.29 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES set:
Output 500 frames in 40.75 seconds (12.27 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set:
Output 500 frames in 37.51 seconds (13.33 fps)

Vapoursynth R44-test1, VS_NO_LARGE_PAGES not set: (on an administrator command prompt)
Windows VirtualAlloc bug detected: page still mapped
Output 500 frames in 39.67 seconds (12.60 fps)

The time variations could be related to the antivirus scanning my external USB disk in the background

Almost all group policies are just regedits with airs, and work the same on Home once set: This one is HKEY_CURRENT_USER\System\CurrentControlSet\Policies DWORD SeLockMemoryPrivilege value 0x1. Reboot after setting.

ChaosKing
17th April 2018, 16:35
I just tried the 4k code snipped by HolyWu + PS code above and it is SLOW:
Output 1000 frames in 172.86 seconds (5.78 fps) | 15% CPU load :-/

With "$env:VS_NO_LARGE_PAGES = 1"
Output 1000 frames in 24.06 seconds (41.55 fps) | 75% CPU load

p.s. I have 16gb of ram.

ChaosKing
17th April 2018, 22:33
Now with core.max_cache_size = 32768

Output 1000 frames in 16.40 seconds (60.96 fps)
$env:VS_NO_LARGE_PAGES = 1
Output 1000 frames in 16.24 seconds (61.59 fps)

From 40 to 60fps, nice speed up! CPU load was 100% now.