Log in

View Full Version : Grid plugin usage.


Rob105
3rd June 2023, 09:45
Grid (http://avisynth.nl/index.php/Grid) plugin is very unintuitive, i used manyPlus version for Avisynth+

Usage described here (http://www.avisynth.nl/users/vcmohan/Grid/Grid.html) (its same as instruction coming with plugin).

However sf and ef properties do not work, no way to specify grid display to start/end from frame number?

FFmpegSource2("C:\vid\00007.mp4")
Grid(last, lineint=60, bold=2, vbold=2, color=$cccccc, bcolor=$AA0000, vbcolor=$AAAA00, grid=true, axis=false)


Also if any problem it simply shows error File "Grid.avs" does not have a video stream., not saying what the problem is, so troubleshooting is close to impossible.

StainlessS
3rd June 2023, 13:40
V.C Mohan aint been around since Aug 2022.
You could try PM him, and/or email him, see http://www.avisynth.nl/users/vcmohan/vcmohan.html

V.C, is I think 80+ Y.O, you may not be successful.

From an Old source for grid that I have, [EDIT: AvisynthPluginInit2, ie avisynth 2.58]

// Calls the constructor with the arguments provied.
}
// The following function is the function that actually registers the filter in AviSynth
// It is called automatically, when the plugin is loaded to see which functions this filter contains.
/*
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
{
env->AddFunction("Grid", "cii[lineint]ii[vbold]ii[bcolor]i[vbcolor]i[grid]b[axis]b", Create_Grid, 0);

return "Grid Plugin";
}

[COLOR="red"]*/

the 'sf' and'ef' args [ii in red] are NOT optional, however that whole block is commented out using "/* ... */" style comments, perhaps came from some other
dll source which had Grid() as one of many functions.

Source linked for separate Grid() plugin on Wiki uses this

env->AddFunction("Grid", "c[B][sf]i[ef]i[lineint]i[bold]i[vbold]i[color]i[bcolor]i[vbcolor]i[grid]b[axis]b", Create_Grid, 0);

which shows both 'sf' and 'ef' args as optional.

Looks to me like current wiki dll (ii, not optional, "Grid Does not have a named argument 'sf'") and current wiki source ([sf]i[ef]i, are optional), not from the same version project.

StainlessS
3rd June 2023, 17:15
Further to above.

Comments in above post for 21 Mar 2017 x64 version.
The later 25 June 2020, Grid_2_6.zip is x86 only, no x64 version.

I'll try to rejig versions for v2.58, v2.6, v2.6 Avs+ x86 and x64. (just incase V.C. does not make a show)

StainlessS
4th June 2023, 01:29
OK, maybe this of use, maybe not.
Grid_25.dll, Avs v2.58 colorspaces only.
Grid_x86.dll, Avs v2.6 Std 8 bit colorspaces only, except YV411.
Grid_x64.dll, Avs v2.6 Std 8 bit colorspaces only, except YV411.

https://www.mediafire.com/file/fn08y4pmw7j97j2/Grid_x86_x64_dll_v2.00_20230604.7z/file

Fixed a couple of very minor bugs.

Txt file, Included in zip,

Supports All 8 bit AVS26 colorspaces except YV411. [x86 and x64 dll's, _25 dll is AVS v2.58 colorspace only]

NOTE, despite ManyPlus version docs of Grid, it has had Sf, Ef args removed [StartFrame, EndFrame]. [EDIT: Sf, Ef OK in this version]
Grid dll FilterName Grid() will conflict with ManyPlus Grid() Filter.
[Can call via Grid_Grid() or ManyPlus_Grid() to avoid conflict]


I'm not setup for v2019+ VS compiler, and have yet to figure out how the new stuff works for Frame Properties etc,
and would take me some time to get up to speed, so above is only for 8 bit AVS v2.6 Std Colorspaces.

Also Note, ManyPlus Grid(), will crash on YV411. [presumably the older versions of Grid() will do too]

EDIT: ONLY VERY BRIEF testing and only on x64 version, original source used was AVS 2.6 std colorspace only, the x86 Grid_2_6 source code. [incl in zip]
Report any problems.

EDIT: Added Version Resource to the dll's as below.
https://i.postimg.cc/S2yYxFcs/Grid-Version-Resource.jpg (https://postimg.cc/S2yYxFcs)
Assigned a version of 2.0.0, V.C, tended to just give a date or AVS version eg 2.6 for Avs v2.6.

Rob105
5th June 2023, 07:54
Report any problems.

Thanks for follow up, i did not manage to make your plugin work at all, removed all old versions and installed your DLL.

How i meant to call it Grid_Grid or Grid? Neither one work both x86 and 64bit versions.

P.S. I am not good with color spaces and YUV etc, perhaps it was an issue, but i used uncompressed AVI and same problem, it don't work.

vcmohan
5th June 2023, 13:24
Hi. I am 89 years old. I do check occassionally if there are any messages to me.
Grid function is now part of ManyPlus plugin. Long time back I used to provide facility to start at a specified frame and end at a specified frame. I have removed all such facilities as I found no other plugin provides such. Also that can be achieved by use of Trim and + in the avisynth+ script.
As I did not find any user observations on any of my plugin functions I am thinking of announcing my disappearance from this Forum, but now I may continue for one more year.

StainlessS
5th June 2023, 18:27
Hi V.C., nice to see that you're still kicking around :)
The occasional filter does allow for start and end frame, but not that many, I guess its no great loss and you can use Trim() as you say.

Here is my recompile update for bugfix, had copy/paste error.
I've left the sf,ef args alone, I want a separate version of your Grid() for myself anyway [Probably why I had the source from the ManyPlus whotsit].
Perhaps I could rename so as not to confilct with ManyPlus version, maybe Graticule() or something.

NOTE, In Grid() example on Wiki, this is bugged

Grid(last,24,200,25,4,5,$ff0000,$7f0000,$5f0000,true,false)

In red MUST be even, so I changed it in the included HTML to 24.
Also added a "$" before RRGGBB in HTML docs, result = "specified as $RRGGBB"

Sorry Rob105, cocked up the plug, below update to v2.01 fixed.

https://www.mediafire.com/file/5vz9ms92jw0nb4k/Grid_x86_x64_dll_v2.01_20230605.7z/file

Included in AVS folder.

/*
Grid (clip, int "sf"=0, int "ef"=FrameCount-1, int "lineint"=10, int "bold"=5, int "vbold"=2, int "color"=$000000, int "bcolor"=color, int "vbcolor"=color, bool "grid"=true, bool "axis"=false)

int sf, Default 0. display to start from frame number.
int ef, Default last frame of clip. display to end on frame number.
int lineint, Default 10. Line (dotted) interval in pixels. Must be Even AND >= 4, AND <= Height/4 AND <= width/4.
int bold, Default 5. At least 1. Bold line every nth grid line.
int vbold, Default 2. At least 1. Very bold line every nth bold grid line.
int color, Default $000000. Color of grid line.
int bcolor, Default color. Color of bold line.
int vbcolor, Default color. Color of very bold line.
bool grid, Default true. Whether grid lines to be displayed.
bool axis, Default false. Whether axis lines to be displayed.

*/

BlankClip(Color=$FFFFFF)
#ColorBars(Pixel_Type="YV12") # Alternative

ShowFrameNumber

SF = 0
EF = 99 # End @ Frame 99
LINEINT = 10
BOLD = 5
VBOLD = 2
COLOR = $000000
BCOLOR = $FF0000
VBCOLOR = $0000FF
SHOWGRID = True
SHOWAXIS = False


Grid(last,sf=SF,ef=EF,lineint=LINEINT,bold=BOLD,vbold=VBOLD,color=COLOR,bcolor=BCOLOR,vbcolor=VBCOLOR,grid=SHOWGRID,axis=SHOWAXIS)

kedautinh12
6th June 2023, 01:51
@Stainless, can you change the name of plugin and upload to mediafire again?? Thanks

StainlessS
6th June 2023, 02:07
What you want to call it ?

kedautinh12
6th June 2023, 02:43
Gridstain() :D

Rob105
6th June 2023, 05:35
Hi guys, i actually ended up using importing Grid plugin from VirtualDub, because in Avisynth grid plugin has lines that are too thick i just need 1px width solid line, dotted lines i don't like.

If you continue to develop this plugin, please add opacity right now its too bold and covers video frame too much.

Rob105
10th June 2023, 14:28
I run into some interesting bug with Grid Plugin all versions from Avisynth Wiki.

Also 64Bit version of plugin does not even open at all.


v1 = FFmpegSource2("c:\vid\myvid.mp4")

ruller_vert = ImageSource("c:\vid\Ruller-1920px.png").crop(0,0,1080,0).TurnRight.ConvertToYV12()

v1 = StackHorizontal(ruller_vert, v1, ruller_vert)

https://i.postimg.cc/V0zK5nV6/1.jpg (https://i.postimg.cc/kJ1C51Bh/1.jpg)

StainlessS
10th June 2023, 17:10
Well, that looks like a problem with your video source filter, try LSMashVideoSource as it is an ISO (mp4) file.
Source filter seems to have a problem determining the width of your mp4 file.

(Nothing to do with Grid() at all, not even mentioned in your script).
Good idea to find out what the problem is, ie, is it your mp4, or is it your png,
I expect that it is your mp4.
Just insert a "return v1" immediately after ffmpesource2 thingy, I expect it looks weird.

EDIT:
Your png image could take some time for mods to get around to, suggest post on image host site,
eg PostImage.org:- https://postimages.org/
No account necessary, and no time limit before deletion [unless you set one, I think].

Use either "Thumbnail for Forum", or maybe "Image" or similar "for Forum", then paste the link.

Rob105
11th June 2023, 04:03
Well, that looks like a problem with your video source filter, try LSMashVideoSource as it is an ISO (mp4) file.
Source filter seems to have a problem determining the width of your mp4 file.

(Nothing to do with Grid() at all, not even mentioned in your script).
Good idea to find out what the problem is, ie, is it your mp4, or is it your png,
I expect that it is your mp4.
Just insert a "return v1" immediately after ffmpesource2 thingy, I expect it looks weird.


EDIT:
Your png image could take some time for mods to get around to, suggest post on image host site,
eg PostImage.org:- https://postimages.org/
No account necessary, and no time limit before deletion [unless you set one, I think].

Use either "Thumbnail for Forum", or maybe "Image" or similar "for Forum", then paste the link.

You saying image i attached to post not showing because not been approved by moderators yet?

Image https://postimg.cc/rzZ9fMxB

Video https://www.upload.ee/files/15325751/00005_ORIGINAL.mp4.html

StainlessS
11th June 2023, 09:04
There is something wrong with your video source ie ffmpegsource2, suspect an old version.

This works fine here with my ffmpegsource2 or LSmashVideoSource.

Also note the method of being able to return result at any stage of the script, and therefore being able to debug your own script easy.
(better than throwing your hands into the air and screaming, "it dont work").


#v1 = FFmpegSource2("c:\vid\myvid.mp4")
#ruller_vert = ImageSource("c:\vid\Ruller-1920px.png").crop(0,0,1080,0).TurnRight.ConvertToYV12()
#v1 = StackHorizontal(ruller_vert, v1, ruller_vert)

#v1 = FFmpegSource2(".\00005_ORIGINAL.mp4") # works fine for me
v1 = LSMashVideoSource(".\00005_ORIGINAL.mp4") # so does this
#Return v1 # 1920x1080 (50 fps)

ruller_H = ImageSource(".\Ruller-1920px.png",End=0) # END=0, = single frame, else END=1000 by default with result of 1001 frames
#Return ruller_H # 1920x18

ruller_H = ruller_H.crop(0,0,1080,0) # Make width same as v1.height
#Return ruller_H # 1080x18

ruller_vert = ruller_H.TurnRight
#Return ruller_vert # 18x1080

ruller_vert = ruller_vert.ConvertToYV12()
#Return ruller_vert # 18x1080

v2 = v1.Grid() # Apply grid only on video clip
#Return v2

StackHorizontal(ruller_vert, v2, ruller_vert) # voila


Maybe try this link for ffmpegsource2:- https://forum.doom9.org/showthread.php?p=1987560#post1987560

EDIT:
Also, your last line (actually, the script you posted would not work at all and would produce an error message, despite your bad result image)

v1 = StackHorizontal(ruller_vert, v1, ruller_vert)

Assigns to v1, but does not return anything, you need at end of script, either

v1 # Implicit Assign v1 to special Last clip, which will be returned by default if no explicit "Return Last".

OR

Last = v1 # Explicit Assign v1 to special Last clip, which will be returned by default if no explicit "Return Last".

OR

Return v1

OR as replacement for your "v1 = StackHorizontal(ruller_vert, v1, ruller_vert)", just

StackHorizontal(ruller_vert, v1, ruller_vert) # implicit assign to Last clip

StainlessS
11th June 2023, 10:49
Perhaps of use (perhaps not). [not tested too much]


c = LSMashVideoSource(".\00005_ORIGINAL.mp4")
rh = ImageSource(".\Ruller-1920px.png",End=0)
rh = rh.levels(32,1.0,128,0,255,false) # Make rule, a bit more visible.
Apply_RuledGrid(c,rh,true,true)

return last

Function Apply_RuledGrid(clip c, clip rule_h, bool "horiz", bool "Vert", [* Rule args *]
\ int "LineInt", int "bold", int "vBold", [* Grid Args *]
\ int "color", int "bcolor",int "vbcolor", [* Grid Args *]
\ bool "Grid", bool "axis") [* Grid Args *]
\ {
c
ConvertToRGB32() # We only support RGB32 output.
rule_h = rule_h.ConvertToRGB32()
myName = "Apply_RuledGrid: "
horiz = Default(horiz,false)
vert = Default(vert,true)
Assert(horiz || vert,myName+"Horiz and vert both false, nothing to do")
Assert(!horiz || rule_h.width >= c.width,myName+"clip width greater than rule_h width")
Assert(!vert || rule_h.width >= c.height,myName+"clip height greater than rule_h width")
r_h = (!horiz) ? NOP : rule_h.crop(0,0,width ,0)
r_v = ( !vert) ? NOP : rule_h.crop(0,0,height,0).TurnRight
# ALL Grid optionals are defaulted within Grid plugin, not here.
g = Grid(LineInt=LineInt,bold=bold,vBold=vBold,color=color,bcolor=bcolor,vbcolor=vbcolor,Grid=Grid,axis=axis)
corner = (horiz && vert) ? Last.Blankclip(Width=rule_h.height,Height=rule_h.height) : NOP
h = (Corner.IsClip) ? Stackhorizontal(corner,r_h,corner) : (horiz) ? r_h : NOP
m = (r_v.IsClip) ? StackHorizontal(r_v,g,r_v) : g
(h.IsClip) ? StackVertical(h,m,h) : m
}

In BLUE, for ruler, other args for grid.

[clickme, twice]
https://i.postimg.cc/sQzQ3BVZ/Test-01.jpg (https://postimg.cc/sQzQ3BVZ)

EDIT:
OOoops re-posted, had bold and vbold as Bool instead of int.
Also, changed to output of RGB32 (from YV12), makes more sense when 'gridded'.

EDIT:
Moved Rule args before grid args, easier to use eg Apply_RuledGrid(c,rh,true,true)

poisondeathray
11th June 2023, 23:19
Hi guys, i actually ended up using importing Grid plugin from VirtualDub, because in Avisynth grid plugin has lines that are too thick i just need 1px width solid line, dotted lines i don't like.

If you continue to develop this plugin, please add opacity right now its too bold and covers video frame too much.


It's pretty easy to make your own grid using mt_lutspa (masktools2) . You can change the size , colors, overlay opacity etc...

This example uses 16x16 grid (change the 16 if you want different x,y dimensions) . Change the opacity parameter for overlay if you want


video=colorbars(pixel_type="YV12")

grid=video.mt_lutspa(relative=false, expr="x 16 % 0 == y 16 % 0 == | 255 0 ?", u=-128,v=-128)

overlay(video, grid, mask=grid, opacity=1)



https://i.postimg.cc/7LNY2mwS/grid.png (https://postimages.org/)



If you're trying to censor/ mask out that guy's face in post #14 (or anything moving, really, for any video) , use a NLE with a motion tracker. That will be 10x easier , faster, more accurate and actually "stick" to the face instead of randomly wobbling around. Dedicated masking and rotoscoping tools are going to be much better for those types of tasks. Avisynth is the wrong tool for that job . I saw some of your other threads on animated a block , conditional reader, it's a waste of time doing it that way and it won't even match the motion accurately. The video content motion is not linear to begin with. If you were going to do figure out x, y coordinates, scale - you might as well rotoscope it manually, the latter would still be faster, more accurate (you aren't limited to rectangle shapes)

StainlessS
11th June 2023, 23:53
Some censor type stuff, here:- https://forum.doom9.org/showthread.php?p=1935393#post1935393

EDIT: Manual tracking only.