Log in

View Full Version : VapourSynth Editor 2


Pages : 1 [2] 3 4 5 6 7

_Al_
10th August 2020, 06:37
plane 1 and 2yes plane 1 is U as in your example,
plane 2 is V if clip is YUV. If RGB, then same order R,G,B as 0,1,2 as well.
And right now I am reading the script right from the text files and it needs to be in the folder to work. How do I store the text content inside a c++ file instead?
Not sure exactly what it suppose to be, but if in Python, you can import a module (a script in our case) right from text (a string type) or built in text editor for example and then using it because it is imported. So if coding in Python that handles some text editor, it can run that script from within. Script does not have to be physically on disc or a directory/folder. Not sure how it should be implemented to C++ or if it is possible. In Python you can do:

import vapoursynth as main_vs
import importlib.util
script = 'import vapoursynth as vs\nclip=vs.core.std.BlankClip()\nclip.set_output()' #you fetch this from text editor etc.
main_vs.clear_outputs()
spec = importlib.util.spec_from_loader('my_module_name', loader=None)
vs_module = importlib.util.module_from_spec(spec)
exec(script, vs_module.__dict__)

imported_clip = main_vs.get_output()
imported_clip.set_output()

so basically, you import that created module from text and having that clip available within code where you created that text.
Again not sure how to make it work as coding in C++. You'd need to have some master script in Python all the time and load all other scripts in it. But that's weird.

lansing
10th August 2020, 11:30
Update to r1.5

changelog:
- A new preview filters feature leveraging vs script to assist preview
- Preview filters can be chained

All problem solved, now the preview filters feature should be fully functional and no script needs to be loaded at runtime. The program will read the "xyz.set_output()" from the script in the editor and append the preview filters to it. The combined script will be run to produce the filtered effect.

Right now I have added the YUV channel split script to display YUV channel separately, well I'm not sure what the correct term for it, YUV or Y'CbCr? And are they called plane or channel or component?
I'll add more in the future if I found them useful.

ChaosKing
10th August 2020, 12:37
I get this error SyntaxError: invalid syntax -> clip.set_output()eval("clip.set_output()") if I click on Y in [PF]. Clicking on off does not seem to turn it off, the error msg is still shown.

My script
clip = core.lsmas.LWLibavSource(source=r"E:\ep1_1.vob")
clip.set_output()

lansing
10th August 2020, 14:21
I get this error SyntaxError: invalid syntax -> clip.set_output()eval("clip.set_output()") if I click on Y in [PF]. Clicking on off does not seem to turn it off, the error msg is still shown.

My script
clip = core.lsmas.LWLibavSource(source=r"E:\ep1_1.vob")
clip.set_output()
That because there's no new line between the set_output and eval function. Just put a new line after set_output for now. I'll fix it in next version.

lansing
10th August 2020, 16:31
As far as I know, it's the behavior of all the vsscript previewers. The memory usage goes up to the max cache size, if it was set in the script. Otherwise it feels like there is no garbage collection in VS, and everything is cached indefinitely.

um...looks like the leak can be traced back 7 years ago:
https://github.com/dubhater/vapoursynth-viewer


Notes
Something leaks, maybe 1 megabyte every time a script is (re)loaded.


Now it's 10 MB instead of 1 for every reload. I'll report it.

lansing
10th August 2020, 22:21
r1.6 up, fixed all reported issues

changelog:
- Fixed preview filters dialog Cr Cb button swap
- Fixed preview filter script wrong appending
- Arrow key navigation from time line and preview area works now
- Fixed all editor shortcut keys

ChaosKing
10th August 2020, 23:43
Thx!
I noticed that after switching multiple times between Off Y Cb Cr it kinda breaks. It does not work anymore but there is no error msg. I can scroll but the image does not change. Its like no script is loaded anymore.
I found it very usefull already.

Edit
Can we get right click on tab and close?

lansing
11th August 2020, 00:06
Thx!
I noticed that after switching multiple times between Off Y Cb Cr it kinda breaks. It does not work anymore but there is no error msg.
It's probably from the vs memory leak. It will leak a little every time you run preview script, which is what switching between YCbCr planes is doing. I just tested it, I spammed the buttons until around 1.5G ram and the program crashed.


Can we get right click on tab and close?

You can close with middle click. I'll add it to right click just for the sake of it.

fAy01
11th August 2020, 00:40
1 - Is it possible to add short cut keys to switch between tabs and/or use the mouse scroll button? (Feature available in Avspmod2. Tabs can be accessed with ctrl+1, ctrl+2 and so on. Same with the mouse scroll button).
2 - Double clicking the video region to maximize the window and enter full screen for comparison between two sources. (Feature available in Avspmod2).
3 - At the moment the script window can only be positioned on the left hand side. Is it possible to have it at the top, bottom, and/or right? Or have the option to hide it similar to the script evaluation window in the script window.
4 - Could the bookmark feature be used to generate chapters (txt or xml) with custom configurable presets for chapter names? E.g. Preset 1 [OP, Main, ED, Preview], Preset 2 [Prologue, Opening, Part A, Eyecatch, Part B, Ending, Preview]
5 - Using the bookmarked frames to generate a qpfile for x264?
6 - A place to dock/undock Bookmark Manager.

Kind Regards!

lansing
11th August 2020, 02:11
1 - Is it possible to add short cut keys to switch between tabs and/or use the mouse scroll button? (Feature available in Avspmod2. Tabs can be accessed with ctrl+1, ctrl+2 and so on. Same with the mouse scroll button).
Yeah I'll add those shortcuts, I have been told to use the number button for switching.

2 - Double clicking the video region to maximize the window and enter full screen for comparison between two sources. (Feature available in Avspmod2).

I will have to think about that.

3 - At the moment the script window can only be positioned on the left hand side. Is it possible to have it at the top, bottom, and/or right? Or have the option to hide it similar to the script evaluation window in the script window.

I'm not changing the layout because I think this is the most suitable layout for video script editor. Every space in the ui have served a purpose with minimum waste. Positioning the script window to the top or bottom is a terrible design. Just look at Avspmod, maximize its window and you'll have more than half of your screen filled with empty white space.

I can make it closable and be restored from the Window menu but that's about it

4 - Could the bookmark feature be used to generate chapters (txt or xml) with custom configurable presets for chapter names? E.g. Preset 1 [OP, Main, ED, Preview], Preset 2 [Prologue, Opening, Part A, Eyecatch, Part B, Ending, Preview]
The bookmark manager can generate chapter text file from bookmarked frame with chaptername and that's the farthest I would go. You'll have to use some better chapter specific programs for those features.

5 - Using the bookmarked frames to generate a qpfile for x264?
6 - A place to dock/undock Bookmark Manager.

I don't know what qpfile is and there's no more room to dock the bookmark manager.

fAy01
11th August 2020, 09:27
I don't know what qpfile is and there's no more room to dock the bookmark manager.

qpfile is a text/txt file with a list of I frames for chapter creation. Following is an example:
0 I -1
2158 I -1
16688 I -1
17084 I -1
30331 I -1
32490 I -1

Make the bookmark manager window dock with the script window. Similar to the tab implementation.

feisty2
11th August 2020, 10:49
I wonder if it's possible to write plugins for vseditor (not vaporsynth)
certain tasks like mask drawing could really benefit from GUI and it's painful to write a standalone GUI application for these things.
Ideally, a vseditor filter should accept a video clip and a set of coordinates (spatial coordinates x, y and temporal coordinate t).
the user opens the "preview" window and clicks around and vsedit automatically generates an array containing the coordinates selected by the user, and the user can then pass the array to a vseditor filter.

lansing
11th August 2020, 15:38
I wonder if it's possible to write plugins for vseditor (not vaporsynth)
certain tasks like mask drawing could really benefit from GUI and it's painful to write a standalone GUI application for these things.
Ideally, a vseditor filter should accept a video clip and a set of coordinates (spatial coordinates x, y and temporal coordinate t).
the user opens the "preview" window and clicks around and vsedit automatically generates an array containing the coordinates selected by the user, and the user can then pass the array to a vseditor filter.

You'll have to show some sample image about the concept because I don't know what mask drawing is. What do you mean by "opens the "preview" window and clicks around", what is supposed to be in the window?

I was also thinking about adding plugin support like virtualdub, for 3rd party plugin to be able to write plugin for vapoursynth while at the same time be able to use vseditor as a frame source for their own gui. But I still don't know how this can be tied back to the script.

feisty2
11th August 2020, 16:12
mask drawing is something like manual image matting, the user selects an area of the image by drawing a closed curve and it creates a mask that separates what's inside the curve and what's outside the curve, you can apply different filters to each part then assemble them using std.MaskedMerge, what it creates is the "mask" argument of std.MaskedMerge.

suppose there's this mask drawing filter Matte(clip, trace), where "trace" is a list of control point coordinates sampled from the closed curve drawn by the user, for a 100x50 rectangular region with its top-left corner located at (0,0), "trace" should be [[0,0], [0,100],[50,0],[50,100]], the user should be able to open the preview window and click a "select mode" button or whatever, then click the pixels at (0,0), (0,100), (50,0), (50,100), and vsedit should automatically print something like "ctrl_points = [[0,0], [0,100],[50,0],[50,100]]" in the script, then the user can create the mask by calling "Matte(clip, trace = ctrl_points)"

feisty2
11th August 2020, 16:26
basically, this is what I'm talking about
https://i.imgur.com/dU6bpgb.png

poisondeathray
11th August 2020, 16:46
Masks would be a great feature!

It runs on QT, right ? Something like this integrated? Is it possible ?
https://doc.qt.io/qt-5/qpainter.html

lansing
11th August 2020, 16:59
basically, this is what I'm talking about


Okay this should be simple to implement but what is the use for this? Doesn't rectangle mask like this only work for one frame?

feisty2
11th August 2020, 17:11
it is useful for some very careful frame-by-frame video restoration, and sometimes you only need to select a static region across all frames, like the LogoAnalysis virtualdub plugin.

lansing
11th August 2020, 19:50
it is useful for some very careful frame-by-frame video restoration, and sometimes you only need to select a static region across all frames, like the LogoAnalysis virtualdub plugin.

Okay after looking through more similar tools, I think I get the idea. What you're looking for is a marquees(select) tool like from photoshop. And in this case you're specifically looking for the rectangle marquees tool and have it return the selection as in control points.

For now I'll add the rectangle select tool and the lazy rectangle select tool like in Windows Paint and see how it goes.

ChaosKing
11th August 2020, 20:33
It's probably from the vs memory leak. It will leak a little every time you run preview script, which is what switching between YCbCr planes is doing. I just tested it, I spammed the buttons until around 1.5G ram and the program crashed.


Could maybe this next() + del strategy solve this issue?
https://forum.doom9.org/showthread.php?p=1920780#post1920780

lansing
11th August 2020, 21:09
Could maybe this next() + del strategy solve this issue?
https://forum.doom9.org/showthread.php?p=1920780#post1920780

See here,
https://forum.doom9.org/showthread.php?p=1920641#post1920641

Update, here's the log from vseditor after I closed the tab
Core freed but 537600 bytes still allocated in framebuffers

I'll see if there's function in the vsapi to free those buffers.

lansing
11th August 2020, 21:19
qpfile is a text/txt file with a list of I frames for chapter creation. Following is an example:
0 I -1
2158 I -1
16688 I -1
17084 I -1
30331 I -1
32490 I -1

This can be set in the delimiter in the setting. I'll make it to read "new line" symbol and it should be good.


Make the bookmark manager window dock with the script window. Similar to the tab implementation.
There is no room, the log window is already under the script window.

l33tmeatwad
11th August 2020, 23:15
Took some time today to try and add in missing includes to try and get to compiled on Ubuntu, ran into an issue this this:
bool ScriptEditor::slotFind(const QString &a_text, const QTextDocument::FindFlags &a_flags, bool a_useRegEx)
{
QTextCursor cursor;
if (a_useRegEx == true) {
QRegularExpression re(a_text);
return find(re);
} else {
return find(a_text, a_flags);
}
}
What exactly is "find()", it's not declared, if it's a standard fuction or something it probably needs to to be defined manually to work on other platforms, looks like Windows is VERY forgiving for leaving out includes.

lansing
11th August 2020, 23:31
Took some time today to try and add in missing includes to try and get to compiled on Ubuntu, ran into an issue this this:

What exactly is "find()", it's not declared, if it's a standard fuction or something it probably needs to to be defined manually to work on other platforms, looks like Windows is VERY forgiving for leaving out includes.

The find() is from Qt's QPlainTextEdit class, which is what my class was extended from.

l33tmeatwad
11th August 2020, 23:36
The find() is from Qt's QPlainTextEdit class, which is what my class was extended from.
Hmm...odd, still getting the following error on compile:
../../vsedit/src/script_editor/script_editor.cpp:582:23: error: no matching function for call to ‘ScriptEditor::find(QRegularExpression&)’
582 | return find(re);

lansing
11th August 2020, 23:54
Hmm...odd, still getting the following error on compile:
../../vsedit/src/script_editor/script_editor.cpp:582:23: error: no matching function for call to ‘ScriptEditor::find(QRegularExpression&)’
582 | return find(re);

Maybe your Qt version is older than Qt 5.13? That's when this overloaded function was introduced.

l33tmeatwad
12th August 2020, 00:16
Maybe your Qt version is older than Qt 5.13? That's when this overloaded function was introduced.That would be why, Ubuntu 20 uses Qt 5.12 (LTS). Looks like I won't be able to recommend this until probably the next round of LTS Linux releases. Now as for compiling with Qt 5.13+, the issue I mentioned before keeps it from compiling on macOS:
../../vsedit/src/script_templates/templates_dialog.cpp:34:37: error: no viable conversion from
'QVector<vsedit::VariableToken>' to 'std::vector<vsedit::VariableToken>'
std::vector<vsedit::VariableToken> variables =
I'm not sure why this is happening as the code there is the same as r19 of the original vsedit, so something in the pipeline that changed is probably causing that error. Not sure why it's happening on macOS and not in Windows, I haven't tried on Linux yet as setting up Qt newer than the distributed packages is kinda annoying.

lansing
12th August 2020, 02:17
That would be why, Ubuntu 20 uses Qt 5.12 (LTS). Looks like I won't be able to recommend this until probably the next round of LTS Linux releases. Now as for compiling with Qt 5.13+, the issue I mentioned before keeps it from compiling on macOS:
../../vsedit/src/script_templates/templates_dialog.cpp:34:37: error: no viable conversion from
'QVector<vsedit::VariableToken>' to 'std::vector<vsedit::VariableToken>'
std::vector<vsedit::VariableToken> variables =
I'm not sure why this is happening as the code there is the same as r19 of the original vsedit, so something in the pipeline that changed is probably causing that error. Not sure why it's happening on macOS and not in Windows, I haven't tried on Linux yet as setting up Qt newer than the distributed packages is kinda annoying.

There's a QVector container class in the lines, so maybe it's the same reason as the other one. I'm using Qt 5.14.2.

l33tmeatwad
12th August 2020, 02:46
There's a QVector container class in the lines, so maybe it's the same reason as the other one. I'm using Qt 5.14.2.
Using 5.13+ fixed the other issue, so this is probably not related. I tried 5.13, 5.14, & 5.15.

fAy01
12th August 2020, 03:42
There is no room, the log window is already under the script window.

It's been done in wobbly.

https://i.imgur.com/66Q2bIS.png

https://i.imgur.com/BiWMtuj.png

lansing
12th August 2020, 04:06
It's been done in wobbly.


I'm not sacrificing the space of the two main components for a tool window.

lansing
12th August 2020, 05:31
R2 released.

changelog:

r2: [2020-08-12]
- Disabled mouse scroll to scroll a zommed preview because it doesn't make sense to be only able to scroll one axis
- Preview zoom in scroll bar position are remembered for similar clips in a group
- Fixed preview zoom raito not having immediate effect when change tabs
- Script window can be hidden and restore now
- Added close tab action when right click on tab
- Added shortcuts to switch tab by number keys, available keys are 1-9
- Fixed all editor shortcut keys
- Arrow key navigation from time line and preview area works now
- A new preview filters feature leveraging vs script to assist preview
- Preview filters can be chained
- Per frame properties can be display in frame info dialog now
- Added menu options to toggle the Tools widget and its dialogs
- Added a copy script to new tab function
- Added right click and middle click signal to the tabwidget
- Added middle click close tab function
- Added the basic editor copy/paste actions to the menu options
- A find and replace function for the editor
- PreviewArea now uses QPainter for frame drawing instead of QPixmap, which greatly improves performance for zooming
- Zoom ratio cap increases to 25x

poisondeathray
12th August 2020, 05:57
Thanks for the update

typo for tab name is "untitiled" instead of untitled



- Added shortcuts to switch tab by number keys, available keys are 1-9

I can't get this to work. Is it activated yet ?

lansing
12th August 2020, 06:15
Thanks for the update

typo for tab name is "untitiled" instead of untitled

I can't get this to work. Is it activated yet ?
Have you try it with more than one tab?

poisondeathray
12th August 2020, 06:22
Have you try it with more than one tab?

:) yes , of course


In the bookmark manager, when you push add, is it supposed to be current frame (where playhead is) ? It seems like wrong frame number. Ctrl+b does not work for me either.

lansing
12th August 2020, 06:29
:) yes , of course


In the bookmark manager, when you push add, is it supposed to be current frame (where playhead is) ? It seems like wrong frame number. Ctrl+b does not work for me either.

Are you running R2? No hotkey for bookmark yet.

poisondeathray
12th August 2020, 06:53
Yes R2

Tabs with number key switching works for you?


feature suggestion - extension templates. In avspmod when you drag some video , it will fill in the source filter, path, everything, you just need to hit preview. You can fill in a preferential source filter file for extensions e.g. LSmashVideoSource(***) for MP4 . Currently the r'PATH\video.ext' is filled when you drag a video

lansing
12th August 2020, 07:12
Yes R2

Tabs with number key switching works for you?


feature suggestion - extension templates. In avspmod when you drag some video , it will fill in the source filter, path, everything, you just need to hit preview. You can fill in a preferential source filter file for extensions e.g. LSmashVideoSource(***) for MP4 . Currently the r'PATH\video.ext' is filled when you drag a video

It works for me, I'll test on another machine tomorrow to see how it goes.

The file drop template feature is already there, go to edit->snippet and templates->file drop templates. That why I didn't go into this area. It's just that nobody know how to use it beside Mystery Keeper lol. I have no clue how it work either.

poisondeathray
12th August 2020, 15:24
It works for me, I'll test on another machine tomorrow to see how it goes.


Thanks, this was on a Win8.1 x64 machine

Number key switching for tabs works on VapourSynthMultiViewer for me (but it's buggy in other ways)


The file drop template feature is already there, go to edit->snippet and templates->file drop templates. That why I didn't go into this area. It's just that nobody know how to use it beside Mystery Keeper lol. I have no clue how it work either.

I didn't even look there! Some examples or guide from MK would be nice but I'll try to figure it out

l33tmeatwad
12th August 2020, 15:29
I was going to make the appropriate changes and push a pull request but this is more than I have time for. It's obvious it needs a major overhaul as the code is completely broken on non-Windows platforms. I'd recommend spinning up a Linux VM to work through fixing things if you care about this being cross platform at all, if not I suppose it's fine as a Windows only tool. Side note, I'd recommend actually adding version tags to the repository so that's its easier to use git to find certain versions to help troubleshoot in the future so that specific commits don't have to be tracked down based on the date you uploaded the executables.

lansing
12th August 2020, 16:14
Thanks, this was on a Win8.1 x64 machine

Number key switching for tabs works on VapourSynthMultiViewer for me (but it's buggy in other ways)
I just tested on my Windows 7 machine, the hotkeys work.

ChaosKing
12th August 2020, 16:16
1,2,3 hotkeys do not work for me. I'm on win10 x64

EDIT
It seems the old config needs to be deleted, then it works.

lansing
12th August 2020, 16:26
I was going to make the appropriate changes and push a pull request but this is more than I have time for. It's obvious it needs a major overhaul as the code is completely broken on non-Windows platforms. I'd recommend spinning up a Linux VM to work through fixing things if you care about this being cross platform at all, if not I suppose it's fine as a Windows only tool. Side note, I'd recommend actually adding version tags to the repository so that's its easier to use git to find certain versions to help troubleshoot in the future so that specific commits don't have to be tracked down based on the date you uploaded the executables.

I'll look into Linux support after finish working on the current feature. What VM software and Linux system do I need?

l33tmeatwad
12th August 2020, 16:28
I'll look into Linux support after finish working on the current feature. What VM software and Linux system do I need?I'll send you a PM with more details.

lansing
12th August 2020, 16:31
1,2,3 hotkeys do not work for me. I'm on win10 x64

EDIT
It seems the old config needs to be deleted, then it works.

Hotkey 1,2 and 3 were used for switching between zoom modes in the original version.

poisondeathray
12th August 2020, 16:42
1,2,3 hotkeys do not work for me. I'm on win10 x64

EDIT
It seems the old config needs to be deleted, then it works.


Can you walk me through how to delete the old config ? I deleted the doubled up 1,2,3 entries in the hotkey mapping for zoom, still does not work for me

Thanks


@lansing -

"new script template" is not active in this version. edit > snippets and templates > new script template . In the original version, CTRL+N opens a new script with the contents of the template pasted ("'import vapoursynth as vs, etc..."

Is "time step foward/back" active? The hotkey ctrl+right / ctrl+left moves 1 frame, but I cannot find the field where you adjust the time period (e.g. 1 second or whatever period)



EDIT: NM CK, I got it working. I needed to exit and restart , HOTKEY TAB SWITCHING WORKS!! THANKS LANSING! This was my #1 request

lansing
12th August 2020, 17:07
"new script template" is not active in this version. edit > snippets and templates > new script template . In the original version, CTRL+N opens a new script with the contents of the template pasted ("'import vapoursynth as vs, etc..."

Is "time step foward/back" active? The hotkey ctrl+right / ctrl+left moves 1 frame, but I cannot find the field where you adjust the time period (e.g. 1 second or whatever period)

I haven't test template much. the "new script template" probably got commented out while testing. I'll fix this area altogether later. I'm going to extract their configs to separate text files like with themes because it's so dangerous right now to jam everything into one config file. It pissed me off the last time when I deleted the config file for reset and lost all my snippets.

The time step has also been disabled for now.

poisondeathray
12th August 2020, 17:12
Where are the config, snippets, user preferences , etc... for vsedit settings saved to on Windows ? AppData/Local or something ? I can't find it

ChaosKing
12th August 2020, 17:22
It is in C:\Users\USERNAME\AppData\Local\vsedit.config
Most programs have their own folder, vsedit does not have one.

Or just type %LOCALAPPDATA% in explorer and scroll to the bottom.

poisondeathray
12th August 2020, 17:25
It is in C:\Users\USERNAME\AppData\Local\vsedit.config
Most programs have their own folder, vsedit does not have one.

Same for me , thanks