digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   SansGrip Filters: GripFit (http://www.digitalfaq.com/archives/avisynth/2107-sansgrip-filters-gripfit.html)

SansGrip 01-11-2003 01:16 PM

GripFit
 
The coding of 0.1 is (I think) complete, and now I have to write the docs 8O. Here's a sneak peek for the impatient amongst you ;). No docs, of course, but the source is there if you're feeling adventurous, or want to look for bugs.

Basic usage:

GripFit(clip clip, int width, int height, bool source_anamorphic, bool dest_anamorphic, int overscan, string resizer, int crop_round_width, int crop_round_height, int resize_round_width, int resize_round_height, int luma_threshold, int samples)

Defaults:

clip = last
width = none
height = none
source_anamorphic = false, unless the source is 720x480
dest_anamorphic = false, unless width is 720 and height is 480
overscan = 0
resizer = "BilinearResize"
crop_round_width = 4
crop_round_height = 4
resize_round_width = 16
resize_round_height = 16
luma_threshold = 60
samples = 5

There are two main ways of using it, one for creating "standard" frame sizes, and one for creating 1:1 view-on-the-monitor frames. Example of the latter:

GripFit(height=256)

Specifying no width lets GripFit choose the most appropriate based on rounding etc.

Example of the former:

GripFit(width=528, height=480, overscan=1)

This'll create a properly sized frame for KVCDx3 with 1 overscan block (that is, 8-pixel gaps each side).

Currently, no border is added, hence the command above will probably (depending on the source's dimensions) produce a frame that is 512 pixels wide -- i.e., 528 - 8 * 2.

It'll work with both 1:1 view-on-monitor sources (e.g. AVIs) and "standard" aspect ratio sources (e.g. VCD, SVCD, DVD etc.).

Because there's no docs you must be brave and forgiving if you want to try this release. It's not even on my site yet, so don't blame me for anything that goes wrong :mrgreen:.

I'd greatly appreciate a TON of testing from you guys. Throw what you can at it, all different resolutions, sources, etc. -- for example, I've no Cinemascope source material to test on right now -- and see if you can make it crash. Really pound it and let me know as soon as you see a glitch or if it produces the wrong output for a particular set of inputs.

Have fun... I'll be writing docs :x ;).

kwag 01-11-2003 01:22 PM

YEEEEAHHHH :ole: :flip:
It's play time :mrgreen:

jorel 01-11-2003 01:32 PM

yeah,i play too! :ole: :wink: :D

kwag 01-11-2003 01:40 PM

First note 8)

Here's what I'm using: GripFit( source_anamorphic = true, dest_anamorphic=false, width=528, height=480, overscan=2)

Using "Center" in TMPEG as source aspect, the output looks Anamorphic. Setting "dest_anamorphic=true", it's full screen.

-kwag

SansGrip 01-11-2003 01:43 PM

Quote:

Originally Posted by kwag
Using "Center" in TMPEG as source aspect, the output looks Anamorphic. Setting "dest_anamorphic=true", it's full screen.

What's the frame size of the original? What size is the active frame (i.e. without borders)? What frame size does GripFit produce?

kwag 01-11-2003 01:51 PM

Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
Using "Center" in TMPEG as source aspect, the output looks Anamorphic. Setting "dest_anamorphic=true", it's full screen.

What's the frame size of the original? What size is the active frame (i.e. without borders)? What frame size does GripFit produce?

Using TMPEG reading the .d2v, original is 720X480. After clipping borders with TMPEG, I get 720x366 with top=55 bottom=59.

Edit: GripFit produces 496X336

-kwag

kwag 01-11-2003 02:11 PM

Code:

if(source_is_anamorphic && !dest_is_anamorphic)
        {
                if(dest_dim.width.Defined())
                        h = int( SomethingElseHere?? );

:?:

-kwag

SansGrip 01-11-2003 02:29 PM

Stupid mistake -- forgot to take the existing borders into account when resizing ;). Here's the fix. Told you I shoulda tested it on Cinemascope material... :mrgreen:

SansGrip 01-11-2003 02:32 PM

BTW, here's a helpful script snippet:

Code:

Mpeg2Source("thing.d2v")
GripFit(width=528, height=480)

then work out the borders that TMPGEnc will add (528 - resulting width, 480 - resulting height), then:

Code:

Mpeg2Source("thing.d2v")
GripFit(width=528, height=480)
AddBorders(left, top, right, bottom)
LanczosResize(640, 480)

If it looks right when you play the .avs in Media Player, it'll look right in TMPGEnc too. The final resize converts to square pixels so the AR will be correct on the monitor.

kwag 01-11-2003 02:34 PM

Working like a charm :ole: :ole: :mrgreen:
Have a beer :lol:

-kwag

SansGrip 01-11-2003 02:36 PM

Quote:

Originally Posted by kwag
Have a beer :lol:

No time! Try more sources, try more resolutions! AVIs! DVDs! :mrgreen:

kwag 01-11-2003 02:38 PM

This is what I'm currently using:

Quote:

LoadPlugin("C:\encoding\MPEG2DEC.dll")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\gripfit_preview.dll")
LoadPlugin("C:\encoding\blockbuster.dll")
LoadPlugin("C:\encoding\legalclip.dll")
LoadPlugin("C:\encoding\sampler.dll")

Mpeg2Source("K:\K19\VIDEO_TS\k19.d2v")
LegalClip()
GripFit( source_anamorphic = true, dest_anamorphic=false, width=528, height=480, overscan=2)
FluxSmooth()
Blockbuster(method="noise", variance=.3, seed=1)
LegalClip()
I also tried it with "K-Pax". Worked perfectly too :D

-kwag

SansGrip 01-11-2003 03:03 PM

Quote:

Originally Posted by kwag
GripFit( source_anamorphic = true, dest_anamorphic=false, width=528, height=480, overscan=2)

Note that for DVD sources (actually, anything 720x480) source_anamorphic is true by default. For all destination sizes except 720x480, dest_anamorphic is false by default. So all you really need to use is:

GripFit(width=528, height=480, overscan=2)

I'm planning on implementing a "defaults" parameter, which you'd use like this:

GripFit(width=528, height=480, overscan=2, ..., defaults="save")

From then on, you could just use

GripFit()

and it'll use the saved defaults. The other option will be defaults="clear", which clears the stored defaults and uses the built-in ones.

Quote:

I also tried it with "K-Pax". Worked perfectly too :D
:mrgreen:

Now... if only the forum would stop going down :(. Three times today, for me :x.

kwag 01-11-2003 03:13 PM

Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
GripFit( source_anamorphic = true, dest_anamorphic=false, width=528, height=480, overscan=2)

Note that for DVD sources (actually, anything 720x480) source_anamorphic is true by default. For all destination sizes except 720x480, dest_anamorphic is false by default. So all you really need to use is:

GripFit(width=528, height=480, overscan=2)

Yes. That's the line I was testing previout to your second release. I was trying to force the aspect to see if the output would be correct :)
Quote:


I'm planning on implementing a "defaults" parameter, which you'd use like this:

GripFit(width=528, height=480, overscan=2, ..., defaults="save")

From then on, you could just use

GripFit()

and it'll use the saved defaults. The other option will be defaults="clear", which clears the stored defaults and uses the built-in ones.
Excelent :mrgreen:

Quote:

Now... if only the forum would stop going down :(. Three times today, for me :x.
I might just have to move to another provider. They have some kind of mechanism that "supposedly" blocks an IP if more than 30 concurrent sessions are active. I personally never have more than 3. They told me that if many people connect to the site through a provider proxy, then if the limit of 30 sessions is detected, the server blocks the IP for 30 minutes. They have that for DOS blocking and flooding prevention. It's happening to me too, and I'm getting tired :x .
So it's probably time for me to look for a new provider :idea:

When this happens, please go to www.webwarper.net, and see if you can access the site from there. If you do, then it's defitively the problem, and I'm writing once more to the provider (for the last time :wink: )

-kwag

SansGrip 01-11-2003 03:34 PM

Quote:

Originally Posted by kwag
I might just have to move to another provider. They have some kind of mechanism that "supposedly" blocks an IP if more than 30 concurrent sessions are active. I personally never have more than 3.

I rarely have more than one. It's been happening A LOT recently... Several times a day, sometimes several times an hour. Down for five minutes, up for five minutes, down again, up again...

Quote:

They told me that if many people connect to the site through a provider proxy, then if the limit of 30 sessions is detected, the server blocks the IP for 30 minutes
I'm accessing it through my own web proxy, but no-one else using the proxy (i.e. my wife and kids) are on KVCD.net ;).

Quote:

When this happens, please go to www.webwarper.net, and see if you can access the site from there. If you do, then it's defitively the problem
Good idea, I'll give that a try :).

SansGrip 01-11-2003 03:42 PM

To sum up the usage for everyone until the docs are ready, what you'll mostly be using is this:

GripFit(352, 240, overscan=x)

where overscan is 0, 1, 2, whatever you usually use in FitCD. Or...

GripFit(352, 480, overscan=x)
GripFit(528, 480, overscan=x)
GripFit(704, 480, overscan=x)

and so on. If you want to produce 1:1 square-pixels view-on-your-monitor output, use

GripFit(height=256)

or...

GripFit(height=384)
GripFit(height=190)

or whatever. It'll choose the correct width to maintain the aspect ratio for you.

The option most often changed from default, I suspect, will be the resizer parameter. If you like Lanczos, use

GripFit(width=528, height=480, resizer="LanczosResize")

GripFit doesn't check what you specify as the resizer (you can use anything: bilinear, bicubic, Lanczos, simple, point...), so if you get a weird error try checking for a typo. Note that currently there's no facility for specifying a and b values for bicubic -- that'll be in the next release.

You'll only need to touch the other options if you have some weird situation, like a 720x480 DVD that isn't anamorphic (very rare these days), or your player is able to play anamorphic KVCDs (even rarer). In the first circumstance, you would use:

GripFit(528, 480, source_anamorphic=false)

In the second, you would use:

GripFit(528, 480, dest_anamorphic=true)

Other options are generally best left at the defaults unless you really know what you're doing (e.g. you desperately want Avisynth to crash, in which case go ahead and change the resize_round_width to 1 ;)).

Now back to writing docs...... :evil: ;)

kwag 01-11-2003 03:45 PM

Got one that bombed here SansGrip. It's the movie "Siege". The movie is NOT anamorphic. At least, that's what FitCD says :roll:

Here's the data:

Read from .d2v: 720x480
Cropped borders on TMPEG: 720x274

Read value on TMPEG with GripFit when .avs opens: 496x192

The .avs reads: GripFit( width=528, height=480, overscan=2)

I adjusted the .avs line to: GripFit( source_anamorphic = false, dest_anamorphic=false, width=528, height=480, overscan=2) and now it's perfect :D
The information read from DVD2AVI on the VOBs is: Aspect ratio of 4:3 720x480

After the adjustment, TMPEG opens the .avs as: 496x256 :)

-kwag

kwag 01-11-2003 03:48 PM

I guess we're posting almost at the same time :mrgreen:

SansGrip 01-11-2003 03:50 PM

Quote:

Originally Posted by kwag
The movie is NOT anamorphic.

There's the problem. GripFit assumes all 720x480 sources are anamorphic (a pretty good assumption on the whole, since almost every DVD is anamorphic). As you discovered, you have to set source_anamorphic=false :).

BTW, the reason FitCD knows this and GripFit doesn't is because FitCD gets the information from the .d2v file, while all GripFit has to go on is the clip's frame size and frame rate :).

SansGrip 01-11-2003 03:54 PM

Yummy. This filter is delicious :mrgreen:.

black prince 01-11-2003 10:30 PM

@SansGrip,

I tested GripFit for 352x340, KVCD-LBR,CQ_VBR with no problems:
Here's my script:

mpeg2source("D:\Temp\movie.d2v")
LegalClip()
GripFit( width=352, height=240, overscan=1)
opening=Trim(0,3093)
opening=opening.TemporalSoften(3,8,30)
movie=Trim(3094,145515)
movie=movie.Blockbuster(method="noise", variance=.5, seed=1).FluxSmooth()
credits=Trim(145516,0)
credits=credits.Greyscale().TemporalSoften(3,8,30)
last=opening+movie+credits
LegalClip()
#Sampler(length=24)


Tmpgenc, of course is handling borders. :wink: It will take time
to find all the problems, since you took great care to handle the
most common situations pretty well. This is a useful filter for the
automated encoder "acp". Anamorphic and non-anamorphic are
the only problems that need to be determined by FitCD and I'm
sure you'll find a way to detect this from the .d2v file. Nice work :D

-black prince

SansGrip 01-12-2003 07:54 AM

Quote:

Originally Posted by black prince
Anamorphic and non-anamorphic are
the only problems that need to be determined by FitCD

You don't need FitCD for that. Just run GripFit with something like

GripFit(528, 480, overscan=1)

and, if the output looks vertically stretched in TMPGEnc, use

GripFit(528, 480, overscan=1, source_anamorphic=false)

:)

Quote:

I'm sure you'll find a way to detect this from the .d2v file. Nice work :D
I did think of something, but it would require a modification to mpeg2dec...

SansGrip 01-14-2003 09:28 PM

Ok, here's a new preview version with some bug fixes and a new feature:

Code:

Mpeg2Source("foo.d2v")
GripFit(528, 480, overscan=1)
FluxSmooth()
GripBorders()
LegalClip()

You get the idea. GripBorders() will add black around the frame to fill it out to whatever size you specified to GripFit. In other words, if GripFit produced a frame that was 512x352, GripBorders() would be equivalent to:

Code:

AddBorders(8, 64, 8, 64)
This isn't necessary if you're using the "center" arrange method in TMPGEnc, but makes the package complete and will be helpful to someone using, say, CCE.

I think I'm going to concentrate on docs now, though I might take a look at the mpeg2dec source code and see how hard it would be to add anamorphic source detection...

kwag 01-14-2003 09:44 PM

Quote:

Originally Posted by SansGrip

This isn't necessary if you're using the "center" arrange method in TMPGEnc, but makes the package complete and will be helpful to someone using, say, CCE.

Not only that, but it forces the correct output resolution when you now load the .avs, so you don't have to go back and change the output resolution :wink:
That's great SansGrip :D

Thanks,
-kwag

SansGrip 01-14-2003 09:55 PM

Quote:

Originally Posted by kwag
Not only that, but it forces the correct output resolution when you now load the .avs, so you don't have to go back and change the output resolution :wink:

Hey, I didn't think of that! Bonus :mrgreen:.

muaddib 01-14-2003 10:46 PM

Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
Not only that, but it forces the correct output resolution when you now load the .avs, so you don't have to go back and change the output resolution :wink:

Hey, I didn't think of that! Bonus :mrgreen:.

Yeah! In my opinion it's a great bonus!
Now I can start using it with a BIGGER smile! :yippie:

SansGrip 01-14-2003 11:00 PM

Perhaps coming soon to a filter near you:

Code:

Mpeg2Source("nifty.d2v")
GripCrop(528, 480, overscan=1)
# Filters run on original-size-but-with-existing-borders-removed clip here
GripSize()
# Filters run on new-size-with-no-added-borders clip here
GripBorders()
# Filters run on new-size-with-added-borders clip here

That should offer enough flexibility for everyone...

muaddib 01-14-2003 11:07 PM

Quote:

Originally Posted by SansGrip
Perhaps coming soon to a filter near you:

Code:

Mpeg2Source("nifty.d2v")
GripCrop(528, 480, overscan=1)
# Filters run on original-size-but-with-existing-borders-removed clip here
GripSize()
# Filters run on new-size-with-no-added-borders clip here
GripBorders()
# Filters run on new-size-with-added-borders clip here

That should offer enough flexibility for everyone...

This is getting better and better... :D

kwag 01-14-2003 11:19 PM

Quote:

Originally Posted by muaddib

This is getting better and better... :D

By the hour :mrgreen:

Yoda 01-15-2003 08:28 AM

Sansgrip,
Got an error from avisynth. "caught an access violation at 0x77fcbdef attempting to read from 0xffffff23".
Here's my avs script.
LoadPlugin("D:\Downloads\FitCD\MPEG2DEC.dll")
LoadPlugin("D:\Downloads\gripfit\GripFit_preview.d ll")
LoadPlugin("d:\downloads\sampler\sampler.dll")
LoadPlugin("D:\Downloads\fluxsmooth\fluxsmooth.dll ")
LoadPlugin("D:\Downloads\blockbuster\blockbuster.d ll")
LoadPlugin("D:\Downloads\legalclip\legalclip.dll")
mpeg2source("c:\minority_report\video_ts\minority. d2v")
LegalClip()
gripfit(720, 480,overscan=1)
Blockbuster( method="dither", detail_min=1, detail_max=10, variance=.4 )
gripborders()
LegalClip()
sampler()

Any ideas?

-Yoda

Edit:I just tried 528x480 and now I get a green display in my Tmpgenc. Pushed start just to see and it only encoded the green display.

SansGrip 01-15-2003 08:44 AM

Quote:

Originally Posted by Yoda
Got an error from avisynth. "caught an access violation at 0x77fcbdef attempting to read from 0xffffff23".

Does it work if you comment out GripFit? Does it still crash with:

GripFit(720, 480, overscan=1, dest_anamorphic=false)

?

Are you using the latest preview version (0.0b)?

Yoda 01-15-2003 08:53 AM

Sansgrip,
It's definitely gripfit. I commented out and left gripborders() and got an invalid params error. I commented out gripborders and it works fine. At any thing below 720x480 it get a green screen and no other display.

-Yoda

SansGrip 01-15-2003 08:58 AM

Quote:

Originally Posted by Yoda
I commented out gripborders and it works fine.

Ah, both 720x480 and 528x480 work fine with GripBorders commented out?

Yoda 01-15-2003 09:05 AM

No. I'm getting a green display on all settings now. The first time I used Gripfit avisynth gave me that error from previous. Now all I get is a green display. Could the problem be avisynth?


-Yoda
Edit:I'm using avisynth from 10/29/2002

SansGrip 01-15-2003 09:15 AM

Quote:

Originally Posted by Yoda
No. I'm getting a green display on all settings now.

With and without GripBorders?

Could you load the d2v directly into TMPGEnc and use its clipping dialog to figure out the size of the existing black borders? I can't duplicate this problem with my d2v sources.

Yoda 01-15-2003 09:21 AM

Quote:

With and without GripBorders?

Could you load the d2v directly into TMPGEnc and use its clipping dialog to figure out the size of the existing black borders? I can't duplicate this problem with my d2v sources.
_________________
Regards,
SansGrip
I have gripborders commented out. The borders are top=84, bottom=86, left and right are 8. Are you using avisynth from 10/29/2002?

-Yoda

Yoda 01-15-2003 09:26 AM

:oops: Sorry. top=58 bottom=65, left and right=0. I used the avs on my previous post.

-Yoda

Yoda 01-15-2003 09:36 AM

@Sansgrip
I tried your gripfilter on another source and it works fine. Why is it not working on Minority Report?

Tell me something to look for with the differences between the two sources.

-Yoda

Yoda 01-15-2003 10:16 AM

@Sansgrip
Okay, I tried gripfit with several sources.
K19- worked.
Minority Report-green screen
Bad Company-green screen
Sopranos-green screen

-Yoda

SansGrip 01-15-2003 11:44 AM

Quote:

Originally Posted by Yoda
Are you using avisynth from 10/29/2002?

I believe that's 2.06. I'm using 2.07. You never know, that might be the cause...


All times are GMT -5. The time now is 12:50 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.