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

ortoni
4th June 2020, 00:31
Update to latest master and try again. And specify that it's master you're compiling next time.

And that did the trick! Thanks for this - and thanks for the all-around majorly awesome VapourSynth project. You, Sir, are a scholar and a gentleman.

ortoni
7th June 2020, 06:26
Interesting scripting error arose:

outclip = core.std.StackVertical(clip,clip,clip,clip) gave the error File "src/cython/vapoursynth.pyx", line 1822, in vapoursynth.Function.__call__
vapoursynth.Error: StackVertical: Too many unnamed arguments specified.

Is there not a way to stack the same clip vertically or horizontally, or am I missing something?
TIA

poisondeathray
7th June 2020, 07:05
Interesting scripting error arose:

outclip = core.std.StackVertical(clip,clip,clip,clip) gave the error File "src/cython/vapoursynth.pyx", line 1822, in vapoursynth.Function.__call__
vapoursynth.Error: StackVertical: Too many unnamed arguments specified.

Is there not a way to stack the same clip vertically or horizontally, or am I missing something?
TIA

Enclose in square brackets

outclip = core.std.StackVertical([clip,clip,clip,clip])

feisty2
7th June 2020, 19:17
suggestion: dynamically typed filter arguments should be supported (something like "param: dynamic: opt")
this could greatly simplify the user interface of filters like std.SetFrameProp
"intval", "floatval" and "data" could be unified by a single dynamically typed parameter "val"
there's no need to separate arguments of different data types since whenever the user passes a value to "val", the C++ plugin could query the type of the item associated with "val", then decide how "val" should be handled, example here: https://github.com/IFeelBloated/vsFilterScript/blob/master/include/Map.vxx#L159

ortoni
7th June 2020, 23:54
Enclose in square brackets

outclip = core.std.StackVertical([clip,clip,clip,clip])


...aaaand thank you! Normal service has resumed :)

Myrsloik
10th June 2020, 09:26
Those of you who are interested in audio support should take a look at the latest audio build and the audio development thread (https://forum.doom9.org/showthread.php?t=177623).

nacho
14th June 2020, 04:18
Hi I need some help.
I have a clip with the property 'Scenechange' added to all frames (by WWXD (https://github.com/dubhater/vapoursynth-wwxd)) I want to do the following:
For every scenechange frame I want to extract 4 frames:
The two before it, the marked frame and the 1 after it. I also want to label them with their frame numbers in the source (using Text).

I then want all these series' of 4 frames in sequence as 1 clip.

Can someone help me please? Also FrameEval is runtime evaluated and I don't know if I need that...

Edit:
Here's what I've come up with... it seems fairly slow - vsedit hangs for a bit. And the 4 frames all have the same frame# (of the scenechange), can anyone tell me if this is the right way to go about what I want.

def extractSC(clip):
scdetect = core.wwxd.WWXD(clip=clip)
extract = core.std.BlankClip(clip=scdetect, length = 1)
sceneChangeNr = 0
for i in range(scdetect.num_frames-1):
frame = scdetect.get_frame(i)
if frame.props['Scenechange'] == 1:
sceneChangeNr+=1
before = i - 2
after = i + 2
if i < 2:
before = i
extract += core.text.Text(scdetect[before:after], "Frame No.: " + str(i) '\nScene Change: ' + str(sceneChangeNr))
return extract

stax76
15th June 2020, 19:05
Is there maybe something like AviSynth AddAutoloadDir?

ChaosKing
15th June 2020, 19:15
I don't think so but it's easy to make your own Autoloaddir with something like

import glob
plugins = glob.glob(r"C:\plugins64\*.dll")
for plugin in plugins:
try:
vs.core.std.LoadPlugin(plugin)
except:
print("some err")

stax76
15th June 2020, 19:30
The reason why I ask is in portable mode VapourSynth has an auto load folder defined but I don't want staxrip users to modify anything within the startup folder because then it would be difficult to update staxrip, so for portable mode I'm adding another auto load folder located in the staxrip settings folder, it can be opened in the main menu the same way as the installed auto load folder. I've added code like suggested so no problem.

lansing
15th June 2020, 19:30
It feels like we should have a database for code snippets for all common tasks so other can just copy and paste. It's a lot easier for them than to start everything from scratch.

stax76
15th June 2020, 19:38
Wasn't an issue for me however since staxrip generally uses manual loading and iterating through DLLs of a directory is not difficult, I had asked because I wanted to know the most efficient solution.

Myrsloik
15th June 2020, 23:51
Is there maybe something like AviSynth AddAutoloadDir?

Nope, I do have plans to let it be overridden some day in the maybe not too distant future.

nacho
16th June 2020, 09:23
@HolyWu Sorry I'm pretty new to python and I don't quite understand the logic. I've run your code and it seems to work.

I would think this:


for n in range(clip.num_frames):
for i in range(-1, 3):
target = n + i
if 0 <= target < clip.num_frames and sc_frame_no.count(target):
label_frame_no.append(n)
if not label_frame_no.count(n):
delete_frame_no.append(n)


should be:


for n in range(clip.num_frames):
for i in range(-2, 2):
target = n + i
if 0 <= target < clip.num_frames and sc_frame_no.count(n):
label_frame_no.append(target)
if not label_frame_no.count(n):
delete_frame_no.append(n)


I thought the inner loop range should make target go from 2 before n to 1 after n: range(-2,2) where does (-1,3) come from? For the next bit I would think we want to check if frame 'n' is in the list of scene changes, and if it is then add the surrounding frames (targets) to the list label_frame_no. I now realise this isn't what you're doing, but can't quite understand what's going on. Edit: Ahh you check every frame if it's within 4 frames of a scene change, rather than finding a scene change and then getting the 4 around it.

Also len(sc_frame_no) prints the total number of scene changes on all the frames. I'd like it to start at 0/1 and increment for each group of 4 frames. Sorry I'm asking you to write code for me but it's very frustrating knowing exactly what I want but not knowing how to implement it.

ortoni
19th June 2020, 00:47
The VS docs say "When mode is “h” or “v”, this must be an array of 3 to 25 numbers, with an odd number of elements."

Does that mean a h-only convolution can accept more than 5 coefficients?

Reason I ask is I'm looking to do a 7-"tap" horizontal convolution.

Can't quite see it from the code since there is a lot of cool SSE and AVX going on!

One other quick question: preferred method to input a clip with alpha channel e.g. Apple Animation or ProRes. AVISynth allowed decoding directly to BGR32 iirc, but VS warns off using this format ;-)

TIA

poisondeathray
19th June 2020, 01:50
One other quick question: preferred method to input a clip with alpha channel e.g. Apple Animation or ProRes. AVISynth allowed decoding directly to BGR32 iirc, but VS warns off using this format ;-)



ffms2 with alpha=True

The clip will be [0] in the native pixel format, and the alpha channel will be [1] as Gray

(Lsmash would be ideal, because MOV does not require indexing, but it does not support alpha channel formats. Maybe HolyWu can add it some time in the future)


Not sure about 7x7 convolution

ortoni
19th June 2020, 05:34
Thx @poisondeathray for the ffms2 solution, I'll give that a whirl.

BTW not looking for square 7x7 convolution, but horizontal 7x1, hence the uncertainty.

Myrsloik
19th June 2020, 10:53
Thx @poisondeathray for the ffms2 solution, I'll give that a whirl.

BTW not looking for square 7x7 convolution, but horizontal 7x1, hence the uncertainty.

Yes, you can do that.

feisty2
19th June 2020, 11:48
I see there're quite some changes in vaporsynth.h in the audio branch
will you make a list of all API changes when the audio development is done?

Myrsloik
19th June 2020, 12:17
I see there're quite some changes in vaporsynth.h in the audio branch
will you make a list of all API changes when the audio development is done?

Yes, I always document things when they're done. The audio API is 99% similar to the video one anyway so anyone who wants to start prototyping things can do so. Look at audiofilters.cpp if you're curious.

ortoni
20th June 2020, 11:20
Another possibly dumb question, apologies in advance!
I'm trying to present the R channel of an RGB clip to a plugin which is YUV/Y only.
But core.std.ShufflePlanes(clips=[RGBclip], planes=[0], colorfamily=vs.GRAY) gives a "Resize error 1026: GREY color family cannot have RGB matrix coefficients".
I wasn't expecting that since it looked like ShufflePlanes was kinda designed to do this with minimal error checking. Switching to colorfamily=vs.YUV gives "YUV color family cannot..."

Is there any way around this?

Thx

PS adding audio to VS is possibly the greatest thing since sliced bread.

Myrsloik
20th June 2020, 12:23
Another possibly dumb question, apologies in advance!
I'm trying to present the R channel of an RGB clip to a plugin which is YUV/Y only.
But core.std.ShufflePlanes(clips=[RGBclip], planes=[0], colorfamily=vs.GRAY) gives a "Resize error 1026: GREY color family cannot have RGB matrix coefficients".
I wasn't expecting that since it looked like ShufflePlanes was kinda designed to do this with minimal error checking. Switching to colorfamily=vs.YUV gives "YUV color family cannot..."

Is there any way around this?

Thx

PS adding audio to VS is possibly the greatest thing since sliced bread.

You're not getting the error from ShufflePlanes...

You split the plane but it's still got the _matrix and other properties set to ones that correspond to RGB (Gray format is basically equivalent to a Y plane) so you need to remove/correctly set the _matrix property before resizing.

poisondeathray
20th June 2020, 17:15
Is it possible to get a single vspipe instance to send 2 streams, video and audio , index 0 and 1 or whatever number ?

Myrsloik
20th June 2020, 21:29
Is it possible to get a single vspipe instance to send 2 streams, video and audio , index 0 and 1 or whatever number ?

No. That'd require vspipe to mux the streams into some more complex container and that's a pain in the ass.

Pat357
21st June 2020, 20:36
The VS docs say "When mode is “h” or “v”, this must be an array of 3 to 25 numbers, with an odd number of elements."

Does that mean a h-only convolution can accept more than 5 coefficients?

Reason I ask is I'm looking to do a 7-"tap" horizontal convolution.

Can't quite see it from the code since there is a lot of cool SSE and AVX going on!

One other quick question: preferred method to input a clip with alpha channel e.g. Apple Animation or ProRes. AVISynth allowed decoding directly to BGR32 iirc, but VS warns off using this format ;-)

TIA

As I understand it, both "v" mode and "h" mode can do up to 25 elements, meaning the pixel itself and up to 12 neighbor pixels in both directions from the same row/column.
The "s" mode is limited to a 3x3 or a 5x5 matrix : 7x7 matrix for example will not work.

I guess you need the "h" mode with 7 or 15 elements depending how you count your tabs.
When you say 7 tabs, do you mean using 7 pixels left from the center pixel and 7 right from the center pixel or just 7 pixels in total (= 3 left + center + 3 right) ??
Anyway both 7 and 15 would fit for v/h mode.

LigH
22nd June 2020, 06:56
7 taps (interpolation points) means the actual pixel + 3 in each direction, 7 in total.

As far as I understand the documentation, specifying a horizontal-only kernel works just as assumed.

lansing
27th June 2020, 06:46
I got the error when installing 32 bit version after double clicking the installer.

"Python 3.8 (32-bit) is installed for the current user only. Run the installer again and select "Install for me only" or install Python for all users.


Update: nvm, I was messing with the Windows' environment variable for python that was causing this, removing it fixed it.

Myrsloik
27th June 2020, 10:37
R51-test1 (https://github.com/vapoursynth/vapoursynth/releases/tag/R51-test1)

Go test it. It has plenty of changes in how python environments are handled to fix rare corner cases. Apart from that it's mostly bugfixes.

r51:
updated visual studio 2019 runtime version
fixed compilation when avs+ master is used
fixed lut and lut2 triggering a fatal error when invalid planes were specified
fixed property append operations on non-empty keys not properly copying the underlying data
fixed wave64 headers generated by avfs
fixed infinite loop in expr with certain expressiosn (sekrit-twc)
fixed crash in averageframes with odd number of clips (sekrit-twc)
scale averageframes for integer chroma by distance from grey (sekrit-twc)
several fixes and improvements regarding handling of the active script environment in python (stuxcrystal)
plugin loading now has better error messages (jackoneill)
using get_core() in python now generates a deprecation warning since it's been deprecated for years

DJATOM
27th June 2020, 10:49
So audio will not make it into r51. That's kinda sad

Myrsloik
27th June 2020, 11:33
So audio will not make it into r51. That's kinda sad

You can always use the audio releases if you don't mind the bugs and lack of testing. 100% compatibility with existing scripts is retained but it's simply a bit too untested and missing a few things too many for me to unleash it on the public.

At this point you should consider the master branch (normal releases) as the stable branch with mostly bugfixes. All major development happens in the doodle1 branch (audio support, major code cleanups and and a major api revision). I expect everyone to slowly migrate over time when they feel it's worth it.

It's now been almost 8 years since the first public release and some of the original mistakes and quirks definitely should be fixed.

DJATOM
27th June 2020, 12:04
Btw audioSplice is kind of broken. I tried to figure it out and seems https://github.com/DJATOM/vapoursynth/commit/dfbd1e9ed84febf9af593a1bbedc0ba8c53cef49 fixes it, but at some conditions it now silently crashes. I'm busy with work now and can't debug deeper.

Myrsloik
27th June 2020, 14:22
Btw audioSplice is kind of broken. I tried to figure it out and seems https://github.com/DJATOM/vapoursynth/commit/dfbd1e9ed84febf9af593a1bbedc0ba8c53cef49 fixes it, but at some conditions it now silently crashes. I'm busy with work now and can't debug deeper.

Must only happen with specific combinations of clips merged. I need to know the exact format and length you made it crash with. You're right that reqStartOffset is set in the wrong place and I've fixed that.

vcmohan
28th June 2020, 07:26
You can always use the audio releases if you don't mind the bugs and lack of testing. 100% compatibility with existing scripts is retained but it's simply a bit too untested and missing a few things too many for me to unleash it on the public.

At this point you should consider the master branch (normal releases) as the stable branch with mostly bugfixes. All major development happens in the doodle1 branch (audio support, major code cleanups and and a major api revision). I expect everyone to slowly migrate over time when they feel it's worth it.

It's now been almost 8 years since the first public release and some of the original mistakes and quirks definitely should be fixed. I have developed some plugins for Vapoursynth back in 2014. There after I have been using avisynth+ upto 2017. Recently I got a push from a youngster to upgrade to latest versions. I completed for avisynth+ and want to utilize my free time during the present lock down by upgrading for vapoursynth. It appears a lot of changes happened since then. Request guidance as to which version I should start and link to get the new header files. Also I may try for your almost ready to release version.

Pat357
28th June 2020, 18:29
It seems that the latest audio-enabled version from VS (VapourSynth64-Portable-R51-audio-test4) has broken adding -w or --w64 headers to the output.

vspipe -w myaudio.vpy - | ffplay -i pipe:
does work for the previous VapourSynth64-Portable-audio-test3 (song plays), but is broken again in test4 (invalid/corrupted input reported reported by ffplay).

vspipe --wav myaudio.vpy - | ffplay -i pipe: plays both in test3 and test4.
So WAV header added by --wav still works ok with test4.

Also with test4 :
vspipe -w myaudio.vpy test.w64 (and)
vspipe --w64 myaudio.vpy test.w64
The resulting test.w64 can not be played by any w64 aware player like Foobar, MPV, VLC, FFplay : all players report an invalid/corrupted file.
These also work perfect with test3 : all above players played the resulting test.w64 perfectly

Myrsloik
28th June 2020, 23:51
I have developed some plugins for Vapoursynth back in 2014. There after I have been using avisynth+ upto 2017. Recently I got a push from a youngster to upgrade to latest versions. I completed for avisynth+ and want to utilize my free time during the present lock down by upgrading for vapoursynth. It appears a lot of changes happened since then. Request guidance as to which version I should start and link to get the new header files. Also I may try for your almost ready to release version.

Not much has changed, really. The API is the same and no real changes have happened. The latest headers are included (select the SDK option in the installer). Always use the latest release.

tebasuna51
29th June 2020, 00:52
The length of the 'fmt' Subchunk is wrong and the Subchunk 'data' is not found, the same w64 with previous version:

ChunkID .....: riff ChunkID .....: riff
RiffLength ..: 13824128 RiffLength ..: 13824128
Container ...: wave Container ...: wave
SubchunkID ..: fmt (Length: 40) SubchunkID ..: fmt (Length: 32) <--------
AudioFormat .: 65534 (WAVE_FORMAT_EXTENSIBLE) AudioFormat .: 65534 (WAVE_FORMAT_EXTENSIBLE)
NumChannels .: 6 NumChannels .: 6
SampleRate ..: 48000 SampleRate ..: 48000
ByteRate ....: 1152000 ByteRate ....: 1152000
BlockAlign ..: 24 BlockAlign ..: 24
BitsPerSample: 32 BitsPerSample: 32
ValidBitsPS .: 32 ValidBitsPS .: 32
MaskChannels : 63 (FL FR FC LF BL BR) MaskChannels : 63 (FL FR FC LF BL BR)
SubType .....: 3 (Float) SubType .....: 3 (Float)
SubchunkID ..: data (Length: 13824000) SubchunkID ..: ? <--------
Offset data .: 128
Duration ....: 12 sec., (0h. 0m. 12s.)

Pat357
29th June 2020, 19:04
@tebasuna51 : What tool did you use to retrieve the info you posted from an audio file ? Seems extremely useful with detailed output. Is it public available ?

It's a bit strange that the previous version you say also causes missing info in the w64 header, while om my system ffmpeg was able to play the files. :confused::confused:
What version do you mean by the previous version ? Can you state the date stamps from for example Vspipe ?
The version that worked for me was VapourSynth64-Portable-R50-audio3 compiled on 16/06/2020.
I believe VapourSynth64-Portable-R50-audio3 has been updated without changing the filename or download location, so it could be that I have a different "previous" version than you...

Can you try if the following simple commands work on your previous version ?
vspipe -w myaudio.vpy - | ffplay -i pipe:
vspipe --w64 myaudio.vpy - | ffplay -i pipe:
myaudio.vpy is in fact just a 2-liner :
import vapoursynth as vs
from vapoursynth import core
a1 = core.bas.Source(r"d:\test\audio\samples\mp3\Mena1.mp3", track=-1)
a1.set_output()
All the above works for me when I use the 16/06/2020 version, but is broken in the newest test4 with compile date 27/06/2020.

tebasuna51
29th June 2020, 21:44
@tebasuna51 : What tool did you use to retrieve the info you posted from an audio file ? Seems extremely useful with detailed output. Is it public available ?
Is a very old tool (https://forum.doom9.org/showthread.php?p=1522330#post1522330) than I make long time ago.

It's a bit strange that the previous version you say also causes missing info in the w64 header, while om my system ffmpeg was able to play the files.
Don't worry about old versions, the next one was the better.
In a previous version the headers are 'simple', corrects but without the channelmask info than offer the 'WAVE_FORMAT_EXTENSIBLE' headers.

vcmohan
2nd July 2020, 13:48
Not much has changed, really. The API is the same and no real changes have happened. The latest headers are included (select the SDK option in the installer). Always use the latest release.

In RGB packed samples supported by avisynth the left bottom corner is the 0,0 coordinate. In the RGB24 format of vapoursynth where is this 0,0 ? I am finding in one of my plugins it to be Left Top corner, but in another Left Bottom. My code must be wrong in one of the cases. Request clarify.

feisty2
2nd July 2020, 13:54
vaporsynth plugins do not support packed formats, packed formats are only there for compatibility with avisynth plugins.

Myrsloik
2nd July 2020, 14:12
In RGB packed samples supported by avisynth the left bottom corner is the 0,0 coordinate. In the RGB24 format of vapoursynth where is this 0,0 ? I am finding in one of my plugins it to be Left Top corner, but in another Left Bottom. My code must be wrong in one of the cases. Request clarify.

In planar RGB 0,0 is always the top left corner, just like for YUV.

feisty2
4th July 2020, 04:33
how do I materialize a vpy script that outputs RGB30 using ffmpeg? I'd like to encode the vpy output to r210 (uncompressed 10bpc RGB) with ffmpeg and the y4m tool does not support RGB streams.

stax76
4th July 2020, 11:18
this works here:

ffmpeg -f vapoursynth -i aaa.vpy -c:v r210 aaa.mov

feisty2
4th July 2020, 13:08
where can I find this ffmpeg with vaporsynth extension?

stax76
4th July 2020, 13:36
You can find it in the Apps dialog of staxrip, it provides web, help and download URLs, in many cases it shows a mediafire folder of Patman:

https://www.mediafire.com/folder/vkt2ckzjvt0qf/StaxRip_Tools

poisondeathray
4th July 2020, 17:31
Alternatively, vspipe supports rawvideo . (In ffmpeg, gbrp10le for RGB30)

eg
vspipe RGB30.vpy - | ffmpeg -f rawvideo -pix_fmt gbrp10le -r (framerate) -s (width)x(height) -i - -c:v r210 output_r210.mov

LigH
4th July 2020, 19:46
Also you can set up the media-autobuild suite to compile ffmpeg for you, including all the codecs and features you need. Even combinations of licenses which may not be distributed in public.

vcmohan
13th July 2020, 12:54
I have as input 2 clips A and B. My output C has a copy of B as base on which some new pixels are drawn. I have following questions.
1. Can I specify (ret, B = ret,...) as input string when I want the A clip also be the base for my C. Should I test if they are same and set up a flag for ArInitial, or not required? Can I specify B to be opt and if not specified make it same as ret?
2. If I need to set up a flag then can the arInitial be
// Request the source frame on the first call

vsapi->requestFrameFilter(n, d->node[0], frameCtx);
if( clipsNotSame)
vsapi->requestFrameFilter(n, d->node[1], frameCtx);

Is such construct allowed? Or there is no need to have if statement?
3. In all frames ready section should I use
if(clipsNotSame){
bkg = vsapi->getFrameFilter(n, d->node[1], frameCtx);
i
VSFrameRef *dst = vsapi->copyFrame(bkg, core);
}
else
VSFrameRef *dst = vsapi->newVideoFrame(fi, width, height, src, core);
4. out of 2 methods getting new video frame and copying with bltbit ior using copyFrame, which is preferable?

Myrsloik
13th July 2020, 14:07
I have as input 2 clips A and B. My output C has a copy of B as base on which some new pixels are drawn. I have following questions.
1. Can I specify (ret, B = ret,...) as input string when I want the A clip also be the base for my C. Should I test if they are same and set up a flag for ArInitial, or not required? Can I specify B to be opt and if not specified make it same as ret?
2. If I need to set up a flag then can the arInitial be
// Request the source frame on the first call

vsapi->requestFrameFilter(n, d->node[0], frameCtx);
if( clipsNotSame)
vsapi->requestFrameFilter(n, d->node[1], frameCtx);

Is such construct allowed? Or there is no need to have if statement?
3. In all frames ready section should I use
if(clipsNotSame){
bkg = vsapi->getFrameFilter(n, d->node[1], frameCtx);
i
VSFrameRef *dst = vsapi->copyFrame(bkg, core);
}
else
VSFrameRef *dst = vsapi->newVideoFrame(fi, width, height, src, core);
4. out of 2 methods getting new video frame and copying with bltbit ior using copyFrame, which is preferable?


1. You mean that you have a function that takes two clips and want to see if they're identical? There's no way to compare clips for equality since the pointers are only a reference object and can (and most likely will) be different for the same clip. The most correct way to solve it is to mark the clip B argument as optional and only use clip A. Argument list:
"clipa:clip;clipb:clip:opt;"


2. It's harmless to request the same frame from the same clip twice. If you know it's the same clip it's still slightly faster to avoid doing it tough.

3. Yes, that works.

4. copyFrame, it will always copy the minimal amount of data using an effective method if you're only going to modify a small portion of the frame.

vcmohan
14th July 2020, 07:17
Thanks. Being a novice coder, I use with avisynth the ThrowError mssage having printf format for debugging. For vapoursynth for debugging in the areAllFramesReady section what messaging code should I use so that I can see some values on screen?