Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th May 2020, 22:00   #1  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,290
MeGUI Resizing Functions - AnyResizerMeGUI & CropResizeMeGUI

I wanted to solve an issue with MeGUI's resizing... the inability to use the Script Creator for cropping and resizing using a non-Avisynth resizer, without having to manually edit the scripts it creates, which can be annoying, as every time a change is made in the AVS Script Cretaor GUI, it re-writes the script.

This post is dedicated to the AnyResizerMeGUI script and the functions it contains.
The next post will be dedicated to using the CropResizeMeGUI function as it requires images, so it'll also be a substitute for a help file.

The new version includes a zip file containing Avisynth profiles. It can be imported directly into MeGUI via the "File/Import Presets" menu, so the Avisynth templates don't need to be created manually. Should you not wish to keep them, they're easily deleted.
A bonus function called MeGUISource.avsi is now included. It's sole purpose is to automatically remove the frame rate conversion MeGUI adds to a script for FFVideoSource.
The included AVS templates for CropResizeMeGUI have also been updated.
The new templates now include the Mod & HMod arguments for CropResize, rather than those arguments being modified by the CropResizeMeGUI function automatically.

AnyResizerMeGUI & CropResizeMeGUI 2020-06-23.zip

None of this will be likely to work with DGI Source configured to do the cropping and resizing in the AVS profile. I don't know how that's added to a script.

The AnyResizerMeGUI script contains the following functions. I won't go into too much detail as it comes with a help file. Instead I'll just offer some usage examples. The functions are intended to be used after creating appropriate AVS Profiles (templates) in the Script Creator.

AnyResizerMeGUI()
Returns MeGUI's resizing width and height as a string. The width and height are separated by a comma.
ie 640,480
AnyResizerTooMeGUI()
The same as for AnyResizerMeGUI, only the "a" and "b" arguments are included in the string when a Bicubic resizing option is selected.
ResizerMeGUI()
Returns the selected resizer in the AVS Script Creator as a string.
ie "Spline36Resize"
WidthMeGUI()
Returns MeGUI's resizing width as an integer.
HeightMeGUI()
Returns MeGUI's resizing height as an integer.
CropMod4WMeGUI()
Automatically crops the source to a Mod4 width. See the help file for usage details.

Here's how the above functions are used in an AVS Profile (template).
The first example specifies the Resize8 function for resizing. I use it regularly as it corrects the slight chroma shift that the Avisynth resizers can introduce. It also tells the Resize8 function which resizing kernel to use according to the resizing method specified in the Script Creator profile, or selected in it's GUI.

Code:
<input>
<deinterlace>
<crop>
<denoise>
Eval("Resize8("+AnyResizerMeGUI(Last,"<resize>")+",Kernel="+"""ResizerMeGUI("<resize>")"""+")")
The above would result in the following, assuming MeGUI is resizing to 1280x720 and Spline36Resize is the selected method in MeGUI's script creator.

Code:
<input>
<deinterlace>
<crop>
<denoise>
Resize8(1280,720,Kernel="Spline36Resize")
The next example gives MeGUI the ability to upscale with NNEDI3.

Quote:
<input>
<deinterlace>
<crop>
<denoise>
nnedi3_rpow2(rfactor=2,cshift=ResizerMeGUI(Last,"<resize>"),fwidth=WidthMeGUI(Last,"<resize>"),fheight=HeightMeGUI(Last,"<resize>"))
The above would result in the following, assuming MeGUI is resizing to 1280x720 and Spline36Resize is the selected method in MeGUI's script creator.

Quote:
<input>
<deinterlace>
<crop>
<denoise>
nnedi3_rpow2(rfactor=2,cshift="Spline36Resize",fwidth=1280,fheight=720)
With any luck the included functions should allow the creation of templates that allow MeGUI to use any resizer.

If you don't have Avisynth installed and/or you don't auto-load plugins and scripts, you'll need to include importing the AnyResizerMeGUI script in the template, along with the appropriate resizing plugin or script and it's dependencies.

Last edited by hello_hello; 22nd June 2020 at 21:04.
hello_hello is offline   Reply With Quote
Old 27th May 2020, 23:37   #2  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,290
CropResizeMeGUI

Here's a function for integrating CropResize into MeGUI a little. You crop and resize with MeGUI as usual (almost), but the resizing is done via CropResize (for aspect error free resizing). Naturally the CropResize script is required.

The new version includes a zip file containing Avisynth profiles. It can be imported directly into MeGUI via the "File/Import Presets" menu, so the Avisynth templates don't need to be created manually. Should you not wish to keep them, they're easily deleted.
A bonus function called MeGUISource.avsi is now included. It's sole purpose is to automatically remove the frame rate conversion MeGUI adds to a script for FFVideoSource.
The included AVS templates for CropResizeMeGUI have also been updated.
The new templates now include the Mod & HMod arguments for CropResize, rather than those arguments being modified by the CropResizeMeGUI function automatically.

AnyResizerMeGUI & CropResizeMeGUI 2020-06-23.zip

None of this will be likely to work with DGI Source configured to do the cropping and resizing in the AVS profile. I don't know how that's added to a script.

To use CropResizeMeGUI, you need to create an AVS template, or two or three (AVS Profiles in the script creator). If you don't have Avisynth installed and therefore can't auto-load plugins, importing the two scripts needs to be included in the template(s).

Don't change or remove the OutType argument in the resize line. It tells the function how to behave.

The Resizer argument can be modified or removed. Any resizer with the same cropping arguments as Avisynth's resizers should work, as will the wrapper functions for resizing with different resizers supplied with the CropResize function. If nothing else, CropResizeMeGUI is a way to crop and resize with MeGUI while using a non-Avisynth resizer. If Resizer="" is used for the resizer argument, or it's removed entirely, the resizer specified in the script creator's GUI will be used.

=================================================================================

The first two are for non-anamorphic sources and non-anamorphic encoding only.

Template 1:

Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=1,Mod=2,HMod=2,Resizer="")
Template 2:

Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=1,Mod=2,HMod=2,Resizer="",Info=true)
Here's what they do:

Template 1 gets CropResize to do the resizing, but MeGUI works in the usual way, only without any aspect error.
Here's a pic of a 1080p source being cropped and resized to 16:9 dimensions. There's a bit of aspect error I could reduce by adjusting the top and bottom cropping, but to demonstrate, I won't (click on the thumbnails or the direct links).



How do you know there's no aspect error? That's what the second template above is for. Switch to it, and CropResize will show you what it's done. Under "Total Cropping" you'll see an extra 4.5 pixels were cropped top and bottom to fix the aspect error.



https://i.postimg.cc/kGH0jJ4y/1-MeGUI.jpg
https://i.postimg.cc/TYLMKD7N/2-MeGUI.jpg

=================================================================================

For anamorphic sources only.
Anamorphic encoding must be enabled, but the source is resized to square pixel dimensions.
The height shown in the script creator's resizing section is ignored.


The only way I could work-around not being able to obtain the original source display aspect ratio from MeGUI in a script automatically was to use it's anamorphic encoding ability to encode non-anamorphically, so it's highly recommended that anamorphic encoding be enabled in the AVS profile when creating the templates. A little confusing at first, but if you give the templates appropriate names you get used to it.

Anamorphic encoding is enabled, but the source is resized to square pixel dimensions. You choose the width in the script creator and CropResize picks the height. The result is pretty much the same as resizing an anamorphic source to square pixels with MeGUI on it's own, minus any aspect error, plus external resizer support. You can specify the height mod when creating the template independently of the mod setting in the script creator. I set it to a Mod4 height here (without the HMod argument the default is Mod2).

It's highly recommended that anamorphic encoding be enabled in the AVS profile when creating the templates.

Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=2,Mod=2,HMod=4,Resizer="")
Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=2,Mod=2,HMod=4,Resizer="",Info=true)




https://i.postimg.cc/Qd12brrp/5-MeGUI.jpg
https://i.postimg.cc/T1h8qLRw/6-MeGUI.jpg

=================================================================================

For anamorphic encoding only.

The next two are only for anamorphic encoding, so it's highly recommended that anamorphic encoding be enabled in the AVS profile when creating the templates. The second one provides information MeGUI doesn't, such as the dimensions of the cropped picture, and the output pixel/sample aspect ratio and display dimensions. It doesn't need to fix aspect error. If the acceptable aspect error is set to zero in the AVS profile, there won't be any, but regardless of that, the output DAR used by CropResize is the same as the DAR specified by MeGUI in the script. MeGUI's cropping can't be displayed by CropResize as it only sees the cropped source, so everything shown is post cropping.

Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=3,Mod=2,HMod=2,Resizer="")
Code:
<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=3,Mod=2,HMod=2,Resizer="",Info=true)




https://i.postimg.cc/tRmGR55V/3-MeGUI.jpg
https://i.postimg.cc/BQrWHnRS/4-MeGUI.jpg

=================================================================================

For all the above, the resizer selected in the AVS Script creator will be used when no resizer is included in the template, however for the Bicubic options, the additional parameters can't be passed along to CropResize (it was designed to handle that sort of thing differently) so no matter which Bicubic resizing you select, the end result will be Bicubic resizing with the default Avisynth arguments.

Last edited by hello_hello; 22nd June 2020 at 21:14.
hello_hello is offline   Reply With Quote
Old 1st June 2020, 04:37   #3  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,290
There's a new version dated 2020-06-01 in the opening post. It now includes Avisynth Profiles that can be imported into Avisynth, and there's a help file explaining each profile in more detail.

There's also some slight changes to the CropResizeMeGUI function.
CropResizeMeGUI now switches the CropResize function to NoResize=true when MeGUI isn't adding resizing to the script. Because of this, it now also sets Mod2 as the default width and height mod for CropResize (which is normally Mod4). This prevents CropResize from adjusting the cropping to make the width or height Mod4 when resizing is disabled, even though Script Creator's cropping might only be Mod2.
Some error messages have been added to hopefully make it harder to use CropResize incorrectly (the OutType argument needs to be used correctly).

Last edited by hello_hello; 9th June 2020 at 11:11.
hello_hello is offline   Reply With Quote
Old 1st June 2020, 15:27   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,279
More MeGUI fancy footwork, alas I only ever do that stuff by hand, only use MeGUI as encoder,
but is very enlightening that you can use MeGUI in such a way.
Thanks for the education.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 22nd June 2020, 21:07   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,290
I've re-written a lot of the CropResizeMeGUI function. It still works exactly as before (the examples posted earlier will still work) but it now includes all the CropResize arguments, so it can be used in a similar way, only with MeGUI doing the cropping and resizing.

There's also a new version of CropResize here.

There's MeGUI limitations that are hard to work around.... mainly not being able to automatically add the original source aspect ratio to a script before cropping so CropResize can see it, or not being able to freely resize with MeGUI when anamorphic encoding is enabled (you can only choose the width)... so having the CropResize arguments available for CropResizeMeGUI will really only be useful for experienced users of the CropResize function. Here's one example though.....

I want to take a 720p source (1280x544), crop the side crud, and resize for a 16:9 DVD while adding borders to suit. If you don't want to be playing with a calculator you could start with the following template, normally used for resizing a non anamorphic source with CropResize.

<input>
<deinterlace>
<crop>
<denoise>
CropResizeMeGUI("<resize>",OutType=1,Mod=2,HMod=2,Resizer="")

This would be the 720p source (thumbnails):



With MeGUI you'd crop and resize to (NTSC) DVD dimensions.
CropResize crops a heap of picture from the sides to prevent aspect error (which we don't want to do) and it looks like this:



The resizing line has become:
CropResizeMeGUI("Spline36Resize(720,480) # Spline36 (Neutral)",OutType=1,Mod=2,HMod=2,Resizer="")

Next we add a couple of new arguments to the resizing line for CropResize:
CropResizeMeGUI("Spline36Resize(720,480) # Spline36 (Neutral)",OutType=1,Mod=2,HMod=2,Resizer="", OutDAR=16.0/9.0,Borders=true,ColorMode="709-601")

And finally we refresh the preview and have an NTSC 16:9 picture with borders:



I added the CropResize arguments to CropResizeMeGUI after realising for me they'd be useful, but they probably won't mean much unless you're familiar with the CropResize function and know how to use it.

The new version is dated 2020-06-23.

Last edited by hello_hello; 22nd June 2020 at 21:16.
hello_hello is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.