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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th April 2010, 23:20   #1  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
SimpleSlugUpscale - Scaling helper script, arbitrary size and PAR input/output

Latest release (currently 1.13)

SimpleSlugUpscale is a QTGMC-based helper script for AviSynth 2.5.x, designed to ease the process of cropping, scaling, and/or letter/pillar/windowboxing clips from one size and shape to another, while taking pixel and display aspect ratios into account.

There are no requirements for progressive input, but interlaced footage needs QTGMC and its dependencies, all of which are linked from that thread. I've also prepared a brief tutorial on the use of SimpleSlug for upscaling, but it's mainly for people unfamiliar with Avisynth.

Full documentation is available in the script itself, but the basics are as follows:

1.) If your input is progressive, set prog=true
2.) If your input is widescreen NTSC DV, widescreen PAL DV, or 1440x1080 HD with a DAR of 16:9, set widein=true
3.) Set size to one of the presets from the following list:

Code:
name		dimensions				PAR	interlaced?

deint		same as input				same	no
square		square pixel equivalent of input	1:1	no
480sq		640x480					1:1	no
360sq		640x360					1:1	no
DVfullpNTSC	720x480					10:11	no
DVfulliNTSC	720x480					10:11	bottom field first
DVfullpPAL	720x576					12:11	no
DVfulliPAL	720x576					12:11	bottom field first
DVwidepNTSC	720x480					40:33	no
DVwideiNTSC	720x480					40:33	bottom field first
DVwidepPAL	720x576					16:11	no
DVwideiPAL	720x576					16:11	bottom field first
720p		1280x720				1:1	no
1080pana	1440x1080				4:3	no
1080iana	1440x1080				4:3	top field first
1080psq		1920x1080				1:1	no
1080isq		1920x1080				1:1	top field first
So, if you have progressive, anamorphic input, and you want 1920x1080p output, you'd use this:

Code:
SimpleSlugUpscale(prog=true,widein=true,size="1080psq")
To get a look at the default settings in action, see this NTSC DV original scaled up to 720p: http://www.gyroshot.com/files/simple...e-defaults.mp4 Compressed with x264 revision 1745, 32 bit, 8 bit depth from x264.nl, using --preset slower --tune fastdecode --keyint 300 --sar 1:1.

On top of that, here are some sample frames (from footage I shot or generated myself, and all hosted on my own webspace) to give you an idea of what can be achieved with SSU:









To give a little background on the origin of this thing, I've been a member of the DV Info Net forums since 2003, and in the past few years the subject of SD to HD upscaling has occasionally cropped up. With more and more people getting into HD video production, now and then someone would find themselves needing to stick an old SD clip into an HD project, and they weren't always elated with the results. Having spent several years toying with Avisynth in my spare time, and having discovered the wonder of TempGaussMC, I took the opportunity in one of those discussions to recommend that combination for the task of deinterlacing and upconversion, and I walked another member through the process of installing all the software and piecing together a script.

When the subject came up again in February 2010, I started preparing an updated, better informed, much cleaner and hopefully more understandable tutorial, and swiftly realized how complicated the whole thing was to explain. I thought a script to take care of as many of the details as possible would be a good idea, hence SimpleSlug. "Simple" for the few adjustments necessary to get usable results, "Slug" to reinforce the lengthy nature of the processing involved.

I finally got around to starting a thread here with the release of version 0.7g, and since then have produced a few more revisions. Over that time the script has inched away from being a DV-to-HD upscaling script and closer to being a general purpose resizing assistant. My choice of default deinterlacer (now QTGMC with the advent of all -Vit-'s handy presets), and default settings, is still based primarily on my testing with DV sources being scaled to 720 output, but the script handles a bunch of other things, too.

I can't pretend to be an expert, and though I've done my best to keep this script clean and offer a set of useful features, I'm certainly not averse to suggestions or corrections. That goes for both the script and the tutorial, which I tried to write as an accurate, but relatively simple way for people who aren't Avisynth gurus to get some use out of QTGMC and the scaling algorithms AS offers.

Please, by all means, feel free to offer ideas for improvements, or let me know that I've done something exceptionally stupid. I have a way of turning everything I do into a Rube Goldberg contraption, and I've already done some real bonehead things in earlier revisions of the script, so I won't be surprised to find yet another way I've taken the long way around in accomplishing some goal. Check the bottom of the script's page to find old versions and you'll be able to see what changes I've made so far; if nothing else I hope this script and its predecessors (the following posts refer variously to versions 0.7g onward) prove useful to learn from.

Last edited by Robert Martens; 14th August 2013 at 00:57.
Robert Martens is offline   Reply With Quote
Old 8th April 2010, 10:08   #2  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
I think this is a great idea.

There are quite a few suggestions in the DV upscale thread (in the DV sub-forum) which could be included. If anyone has time...!

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 8th April 2010, 11:31   #3  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Robert, thanks for producing this and congratulations on a well-written tutorial.

A couple of comments:
- your function expects the input to be 4:3 DV. How about an option to treat the input as 16:9 (anamorphic) DV?
- BicubicResize does not work as the resizer. This can be fixed by using named arguments in place of positional arguments in the resizer calls, eg replace
Code:
Eval("shtrclp." + resize + "(outwidth,outheight,cropleft,croptop,cropwidth,cropheight)")
by
Code:
Eval("shtrclp." + resize + "(outwidth,outheight,src_left=cropleft,src_top=croptop,src_width=cropwidth,src_height=cropheight)")
Gavino is offline   Reply With Quote
Old 8th April 2010, 15:14   #4  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
I haven't run it, but it looks like it's generating interlaced content by generating half-height fields (by simple resizing of the bobbed content) and weaving them.

If so, that's not right at all. You should take the full height bobbed output, and do separatefields().selectevery(4,0,3).weave() You need to specify field order (assumebff() for DV, assumetff() for HD) first. I doubt you'll need a vertical filter since the image will always be vertically soft at this point AFAICT.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 8th April 2010, 18:03   #5  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
Thanks for the feedback, I appreciate the notes!

Quote:
Originally Posted by Gavino View Post
your function expects the input to be 4:3 DV. How about an option to treat the input as 16:9 (anamorphic) DV?
I thought about this a week or so ago, but worried about how to be sure of the input pixel aspect ratio, since as far as I know one can't retrieve that info from the input clip. Now that I spend a few more brain cells on the subject, I realize I could just make it a function parameter, and trust people to know what their input is. Added to my todo list.

Quote:
Originally Posted by Gavino View Post
BicubicResize does not work as the resizer. This can be fixed by using named arguments in place of positional arguments in the resizer calls ...
I note this in the documentation, but named arguments is such a simple solution I'm kicking myself. Thank you for reminding me, I'll get that done in no time.

Quote:
Originally Posted by 2Bdecided View Post
I haven't run it, but it looks like it's generating interlaced content by generating half-height fields (by simple resizing of the bobbed content) and weaving them.

If so, that's not right at all.
You're correct, that's what I'm doing. I was worried I'd end up doing something wrong with the interlaced outputs, but checking my video post-SimpleSlug with AssumeBFF().SeparateFields() (AssumeTFF() for the 1080i outputs) showed no back-and-forth jumping that you usually get with field order problems, and I thought I was in the clear.

Am I to understand it's incorrect even if it seems to be working? I would hardly be surprised, considering how happy I was with myself (that usually means I've done something screwy), and it should prove a fairly simple update in any event.

Last edited by Robert Martens; 8th April 2010 at 20:33.
Robert Martens is offline   Reply With Quote
Old 8th April 2010, 18:47   #6  |  Link
ron spencer
DVD Magistrate
 
Join Date: Dec 2003
Location: Sodor
Posts: 991
very interesting...thanks!!!
ron spencer is offline   Reply With Quote
Old 8th April 2010, 18:58   #7  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Robert Martens View Post
Now that I spend a few more brain cells on the subject, I realize could just make it a function parameter, and trust people to know what their input is.
Yes, that's what I meant.
Quote:
checking my video post-SimpleSlug with AssumeBFF().SeparateFields() (AssumeTFF() for the 1080i outputs) showed no back-and-forth jumping that you usually get with field order problems
It's not a field order problem, but a field alignment problem. Correct interlacing requires the two fields to be vertically offset from each other, so you should see the picture bobbing up and down after a SeparateFields. The fact that it looks OK actually indicates that it's wrong.(!) To get the correct spatial relationship between the fields, you need to do as 2Bdecided says, produce full-height double-rate progressive frames and apply SeparateFields().SelectEvery(4,0,3).Weave().
Gavino is offline   Reply With Quote
Old 8th April 2010, 19:02   #8  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
Quote:
Originally Posted by Gavino View Post
The fact that it looks OK actually indicates that it's wrong.(!)
Excellent, thanks for the briefing! Your two suggestions are already implemented, and now that I understand the interlacing problem I'll get to work on it immediately.

Ron, you're quite welcome!

EDIT: There you go! Haven't updated my site yet, but the new script is up, and the link in the OP will get you the proper file. I figured mistakes like these weren't worth a full point release, so it's version 0.7h now. While I was at it I swapped out the code block with the updated script, too.

I added a boolean parameter, 'widein', that can be enabled to allow widescreen input processing, changed the resizer calls to use named arguments instead of positional, set up the interlaced processing as 2Bdecided described (I now get proper field order AND up-and-down shifting when using SeparateFields() on SimpleSlug's output), moved my Assert for the clip dimensions to the top (no sense worrying about anything else if the clip's the wrong size), and broke a few things onto new lines to keep the script a reasonable width.

Last edited by Robert Martens; 8th April 2010 at 20:20.
Robert Martens is offline   Reply With Quote
Old 9th April 2010, 00:46   #9  |  Link
Undead Sega
Registered User
 
Join Date: Oct 2007
Posts: 713
Even though this seems and looks really great, but at the same time i dont want to sound noobish as well, but is it possible if u can tell me a simple (but slightly detailed) explaination of what your script or function or filter does? Not for me but also for some others here who dont understand
Undead Sega is offline   Reply With Quote
Old 9th April 2010, 04:37   #10  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
Ah, yes, I suppose I can go a little overboard with my writing, sorry.

To try and summarize what I described in the first post, the simplest explanation would be that this script takes an interlaced DV video clip as input, and turns it into one of several HD, or just widescreen DV, output formats (a full table of possible values for the 'size' parameter is available in the downloadable version of the script, linked right up at the top of the thread).

Since there are more funny little details involved in doing this correctly than one might think, the script is meant to take most of the math and decision making out of the user's hands, letting you focus on just getting results. There's plenty to tweak, if you eventually decide to, but the defaults should work quite well for most people.

What does it actually do? Strictly speaking, not much of anything. TempGaussMC handles the deinterlacing, and Avisynth's internal resizers do the upscaling. My script is only supposed to be a less stressful way to put the pieces together. There's a staggering array of possible processing combinations, and my intent was to ease the pain of figuring it all out.

If you want a step by step walkthrough of the script's logic, I suppose I could whip something up, but I don't want to overwhelm you with details. There's not much ground between this explanation and a multi page essay on all the nooks and crannies of how this thing works.
Robert Martens is offline   Reply With Quote
Old 10th April 2010, 02:01   #11  |  Link
Undead Sega
Registered User
 
Join Date: Oct 2007
Posts: 713
hmmm very interesting, so itis basically an upscaler yes? if so, what method of resizing does it use?

i am aware that TempGaussMC is used for deinterlacing, but couldnt one already deinterlaced footage and have it scaled to the desired resolution? Im still confused. And does it have to be DV video specifically as the input?
Undead Sega is offline   Reply With Quote
Old 10th April 2010, 02:25   #12  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
I hesitate to call it an upscaler, since I don't do any of the work myself. The script doesn't examine pixel input values, or calculate new output pixels, it just decides what arguments to pass to the resizer.

The resizing technique, by default, is BlackmanResize, since I've had great success with that in the past; you can, nonetheless, choose whichever scaler you prefer. If you want Spline64, for example, you would pass that in as the value of the 'resize' parameter:

Code:
SimpleSlugUpscale(resize="Spline64Resize",size="720p")
Change 'size' as appropriate, of course, depending on the output you wish to achieve.

Accepting progressive input may be something to add for future revisions, but right now all that's accepted is interlaced. Strictly speaking, of course, the script doesn't actually check for this; if you'd like, try passing in a progressive clip and see what happens. I can't guarantee you'll have success, mind you (all I have for test clips at the moment is a bunch of interlaced PAL and NTSC DV) but you're welcome to give it a shot.

Finally, no, the video doesn't actually have to be in the DV25 format; only "DV size", which means 720x480 and 720x576. The cropping, performed before the upscale of the video, depends on those starting frame dimensions to produce output with as accurate an aspect ratio as possible. Since the script is mainly aimed at the world of video production, which saw a shift from using DV size video in the standard definition days, to all sorts of HD formats over the past few years (the problem becoming that sometimes DV clips need to fit into HD projects; footage from a crash cam, for example, or some critical piece of file footage for a documentary that's only available in DV), I felt the restriction to DV sizes wouldn't be a major hindrance to most people looking to use a script of this sort.
Robert Martens is offline   Reply With Quote
Old 10th May 2010, 09:33   #13  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
Quote:
Originally Posted by Undead Sega View Post
And does it have to be DV video specifically as the input?
It's taken a month, but I've finally addressed this.

I couldn't resist. Someone contacted me about SimpleSlug, asked a few questions, and made a comment in passing that led me to believe they thought the script could handle both anamorphic AND square pixel widescreen footage. At the time I only accepted widescreen DV, so I said to myself "Self, you should tweak the script ever so gently to allow a slightly greater range of input sizes".

Well, everything with me turns into a project, so a few weeks after my brilliant idea (and a few days later than I'd planned, thanks to a family member's computer virus), I give you SimpleSlugUpscale 0.8, which will accept any size input with any pixel aspect ratio, and scale it to any size and PAR output.

I was so happy with previous versions not being wider than a page (as displayed on my 1024x768 CRT), or much taller than one, but that's gone right out the window in favor of legibility. White space abounds in this script, in an attempt to make things more understandable (for myself, if no one else), and as such I must refrain from posting a code block here. Trying to twist it into something that would be readable on a message board could be a bit of a challenge, to say the least.

To summarize the changes, the script now:

-Allows any size and PAR input and output ('outwidth', 'outheight', and 'PARout' are used to define custom target sizes)

-Allows any deinterlacer

-Supports progressive clips by 'prog' boolean, which will bypass deinterlacing and go straight to cropping, scaling and/or boxing

-Has a revised box function that does pillar or letterboxes depending on input and output shape

-Contains ep0 and ep1 parameters, to allow extra parameters for resizer (taps for Blackman and Lanczos, b and c for Bicubic, p for Gauss)

-Contains PARin and PARout parameters, to specify custom pixel aspect ratios (assuming presets don't properly handle your footage)

-Has lost the 'croptop' parameter, its functionality replaced with 'vshift' ('hshift' also available)

-Features 'boxcolor' to set color of pillar/letterbox (integer, either an RGB value or one of the global variables defined in AviSynth 2.5\plugins\colors_rgb.avsi)

-Also features 'boxbgblur' to change amount of blur for "boxbg" size modes

-No longer has YV12 conversion built in; this must be handled before SimpleSlug is called. If you're using RGB footage and an RGB deinterlacer, you won't need any conversion. Same for YUY2 with a YUY2 deinterlacer. By default I'm using TempGaussMC, as always, so you'll need to produce YV12 input with either the 'pixel_type' parameter of your source filter or a ConvertToYV12(interlaced=true) filter before you run SSU.

-Defaults output sizes to mod 8, but this behavior can be changed with 'modw' and 'modh' (will always Floor to the nearest multiple that's below the target output size for a given axis)

-Uses a greater number of TGMC defaults for the "balance" 'qual' setting; with the perspective of some time, I see now my changes had a tendency to make video look too artificial. Bringing back TempGauss' defaults makes for a better result, to my eye. You can certainly adjust things to suit your own taste, if you feel so inclined.

From my research here on Doom9, I only now get the impression that I've ended up duplicating the work of at least a few other members, namely mikeytown2 and his ZoomBox function--among others--but this new set of features seemed useful for SimpleSlug, and I needed the practice working with Avisynth. I wasn't looking to steal anyone's thunder, I just got carried away.

I suppose this script isn't very "simple" anymore, if you use the full array of features, but there are only four things you must do to get this new version working: convert interlaced video to the proper color space for your deinterlacer, set 'prog' true if the input is progressive, set 'widein' true if it's anamorphic, and choose a 'size' option from the list (pay close attention to that, names have been added, removed, and changed from prior releases). Most everything else should be taken care of automatically, so I think the script should still manage to ease the pain of all this scaling business for the uninitiated. Not that I'm such an expert, but you know what I mean.

I've cleaned the script up as much as I can for now; I'd love to sit on this thing until I'm absolutely sure it's perfect, but nothing's ever perfect, so there it is. It's still pre-1.0, anyway, so brace yourself for bugs. Hopefully there won't be many, since I've tested input of quite a few shapes and sizes: 720x480, 720x576, 1280x720, 1920x1080, 1440x1080, 1080x1920 (yes, tall and narrow), 720x1280, 1280x768, 848x480, 320x240, 320x210, 4520x720, 2048x1152, all the sample clips I've been able to find, shoot, or generate. I've tried output that was each of those sizes, plus a dozen others. Some 4:3, some 16:9, some 1:1, some real oddball ratios, and some output dimensions that were literally odd, as is possible with RGB processing.

Upscaling defaults, as it always has, to BlackmanResize, but now I default to Bilinear for downscaling. This can, of course, be overridden by the 'resize' parameter, so everyone's free to choose their poison. I know there's a concern for excessive high frequency detail when downscaling, but in my admittedly informal tests I haven't found any problems with taking 1920x1080 from a Canon XF series camera, or 2048x1152 shot by a RED One, down to NTSC DV resolution. I scaled down to 720x480, compressed with Cedocida, brought the clips into Avid Liquid, then sent them out over the breakout box component outputs to my old Sony CRT, and it was gorgeous, no twitter, didn't look overly sharp. The Canon XF clip was interlaced, and as per the defaults I deinterlaced it with a simple Bob() (triggered if the output height is 1.5 times or more smaller than the input height; less severe downscales use my "low" TGMC preset). Take that with a grain of salt, though, as I haven't had any experience with downscaling issues. If you find my defaults objectionable, feel free to override them, and please let me know if you have suggestions.

I think I've tested a good number of possible input and output scenarios, but there can never be too many tests, so if you have any footage that's an interesting size, shape, or pixel aspect ratio on your hands, I'd appreciate if you could try it out with SimpleSlug and see what happens.

Last edited by Robert Martens; 5th March 2011 at 23:16.
Robert Martens is offline   Reply With Quote
Old 10th May 2010, 17:35   #14  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
I'm sure you could get some good ideas from my scripts in this thread for SimpleSlugUpscale
http://forum.doom9.org/showthread.php?t=135776
mikeytown2 is offline   Reply With Quote
Old 20th July 2010, 23:51   #15  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
When Seagate's big firmware problem was first announced, however long ago that was, I checked my serial numbers with their online form. Three times, over the months following, I was told my drive wasn't affected. An update was available for this model, but not my serial number, so I assumed "it's dangerous to install firmware you don't actually need" and decided not to fix what didn't appear to be broken.

So much for that. A couple of weeks ago, while trying to diagnose a Windows hang by way of analyzing CrashOnCtrlScroll-generated memory dumps, my system refused to POST. More time was spent chasing wild geese than I'd like to admit, but I eventually found the hard drive was the cause (of the BIOS hang; turns out the OS hang was an antivirus/driver interaction). Some research led me to a DIY solution, and while waiting for my USB-to-TTL adapter to arrive, I got the urge to tinker with SimpleSlug again. I went to work on my laptop, and two weeks later I've got an update available for everyone to play with:

SimpleSlugUpscale 0.9

I've since restored access to my desktop, and all my test clips, so I've been able to go through my usual testing procedure for this release. Hopefully there aren't any showstopping bugs.

Believe me, I worry about feature creep as much as anyone else, but in this case the updates were features I would want the script to have if I were using it for a project. I'd previously considered most of the ideas, but dismissed them as too far beyond my skillset. A few months of practice seems to have made a difference, though, because I figured most of them out.

With regard to the script's existing interface, nothing has changed. The same instructions apply as they did for the last version, and the presets are named as they have been for the last few versions (in fact, I've slightly improved the reliability of the 'size' string parsing), so any scripts you're using should still work, even when using positional arguments.

If you'll pardon me, for this post I'm only going to detail changes from the last version; I type enough as it is, and I've been over the basics in this thread already. New users would do well to download the script and read the documentation, which having itself been updated should be a bit easier to handle.

The major improvement for 0.9 is the auto calculation of custom output dimensions when given less-than-complete information. A trivial example would be if you know you want square pixel output that's 640 pixels wide, and has an aspect ratio of 2.35, but you don't know the vertical dimension required to achieve that. Entering

Code:
SimpleSlugUpscale(outwidth=640,DARout=2.35)
would produce this:



Without the Subtitle(), of course, that's just for the purpose of demonstration. 640 / 272 = 2.352941, and you have your aspect ratio! Observant minds will note this paragraph has been edited since I first posted it; I've silently rolled back a change I made in the original release of 0.9 that I only thought I'd sufficiently tested. Used a Ceil() when it should have been Round(), and though the decision to do that was originally made with the best of intent, the corner cases handled by the Ceil() aren't worth the slight aspect ratio error introduced.

This auto-size calculator works whether you enter outwidth or outheight, and doesn't require a display aspect to function correctly. If you only use

Code:
SimpleSlugUpscale(outheight=768)
you'll get square pixel output that's 768 pixels tall and has an aspect ratio that matches the AR of your input. If you enter both outwidth and outheight, your input will be cropped to match the output shape (unless you also enter "box" or "boxbg" for 'size', in which case the input will be padded). Just like 0.8, the crop area can be shifted as necessary with 'hshift' and 'vshift', and should you exceed the maximum values for a given input/output combination, an error message will let you know (and present the maximum).

While I was at it, I added 'boxshifth' and 'boxshiftv' to let you slide the center video left and right or up and down, respectively. These options are better demonstrated than explained, so I've prepared some sample frames (all, including the one above, using input footage I shot or rendered myself, and hosted on my own webspace). I stuck with JPEGs since I'm not showing off compression quality, only frame sizes and shapes (click for full size):

Sample screenshots moved to OP with the release of SimpleSlug v1.00

The "box" and "boxbg" modes also respect modw and modh, even when using boxshifth or boxshiftv, so the borders where the bars meet the center should always fall on multiples of 16, by default (as I said, however, height will be mod 8 for 360 and 1080 presets).

As one last bit of polish, I changed my default 'resize' setting to include an AviSynth version check, so if you're not using 2.5.8 you'll default to Lanczos4 upscaling. I've successfully loaded and used the script in AviSynth 2.5.6, 2.5.7, 2.5.8, and SEt's 2.5.8MT. I think that covers most versions still in use, but correct me if I'm wrong.

How useful all of this will be to anyone, I really can't say, I was just bored and had a lot of free time on my hands. As I said, I just added what I thought the script should, on principle, have if it's going to handle the kind of cropping and resizing I intend it to. Since it was reasonable for me to add this stuff in, I thought it was only the responsible thing to do.

Last edited by Robert Martens; 17th February 2011 at 08:31.
Robert Martens is offline   Reply With Quote
Old 5th November 2010, 15:20   #16  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
All right, I know you're all sick of me bumping this thread every couple of months, so I'll try to get to the point and get out of here.

SimpleSlug v1.00 is now available, with quite a few minor changes, but also a few big ones worth reviewing:

-QTGMC is now the default deinterlacer. The presets from version 0.9, that use TempGaussMC_beta2, are still present, if you prefer doing things that way, but the wide variety of presets available in QTGMC won me over.

-For downscales from interlaced source material, the script now downscales horizontally before deinterlacing. Looks just as good, runs much faster for significant downconversions.

-Thanks to the way I accomplished the horizontal resizing, you can now use a separate vertical resizer, with its own parameters, by way of 'resizev' and 'ep2' and 'ep3'. If you use this option, the existing 'resize' will only determine the horizontal resizer.

-Although my personal motto remains "windowboxing is for suckers", I have finally gotten around to adding windowboxing capabilities to SimpleSlug. Adding "window" to a 'size' preset will override all other custom box dimensions, and keep your input at its original size (accounting for both input and output PAR, so the end result will look the way it should).

-If you want custom windowbox sizes, however, you can instead use "box" in your size preset and define boxwidth and boxheight, together, individually, or in concert with the existing boxvideoDAR.

-If you like you can also use 'bgclip' to dictate a separate background clip. You'll need to make sure ahead of time that it's the same framerate, duration, and colorspace as your main input clip, otherwise you're in for some strange behavior. If it's not a progressive, square pixel clip, you can use 'bgargs' to deal with it properly: the background is generated by calling SimpleSlugUpscale from within SimpleSlugBox, and bgargs is the string of arguments used. I'd recommend sticking with square pixel, progressive clips for your backgrounds and avoiding bgargs altogether, but if you're feeling adventurous the capability is there.

-'boxmode' will let you use Overlay or Layer to stick your center clip on top of the background, and 'boxargs' lets you pass all of your options in. boxmode="overlay",boxargs=""" mode="add" """, for example. Those two filters require colorspace conversions, however, so I've updated my StackVertical/Horizontal nest to allow you to shift the center clip partially or completely offscreen, if you want, just as you can with Overlay and Layer. This change also allows your box to be larger than your output frame on one or both axes.

-In conjunction with the windowboxing capabilities introduced in v1.00, you have preset box positions using 'boxpos'. "Left", "top", "right", "bottom", or a combination of those will set the box in those places to start. This is cumulative with the boxshift parameters, so using boxpos="topleft",boxshifth=32,boxshiftv=32 will stick the box in the top left corner of your output frame, 32 pixels away from each edge, regardless of input and output sizes.

While I was at it, I both cleaned up the Basic Use section to make it more accessible, and added some probably-too-detailed comments throughout the script, to try and clear up my intentions at various points. I also compressed a new sample clip showing off the version 1.00 defaults, and prepared a couple of additional sample frames, all of which you can find with the last batch of samples, relocated from my previous post up to the newly-updated OP.

Once again, I've done a fair bit of testing on this, but I can't catch everything. If you're interested in this script, but can't get it to do something you want it to, let me know and I'll see what I can do!

Last edited by Robert Martens; 17th February 2011 at 08:32.
Robert Martens is offline   Reply With Quote
Old 5th November 2010, 17:23   #17  |  Link
aegisofrime
Registered User
 
Join Date: Apr 2009
Posts: 478
Hi, just stumbled onto this script! I have a question about something I have been attempting to do...

I have a DVD that is a mixture of letterboxed 16:9 content and full 4:3 content. What I want to do is that, for the letterboxed parts, crop away the black bars at the top and bottom, and interpolate that to full 16:9 720x480 resolution. For the 4:3 parts, pillarbox it so that the whole video will be 16:9 aspect ratio. I hope I'm making sense here! Is that possible with your script? Thanks!
aegisofrime is offline   Reply With Quote
Old 5th November 2010, 23:51   #18  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
It should be possible, but I'm not a DVD expert (I mostly work with DV material), so bear with me.

There's a bit of legwork involved, but I'd imagine something like this would work:

Code:
letterboxp1 = last.Trim(0,5000).AutoCrop(mode=0).SimpleSlugUpscale(size="DVwidepNTSC",PARin=10.0/11.0)
fullframep1 = last.Trim(5001,7000).SimpleSlugUpscale(size="DVwidepNTSCbox")

letterboxp1 + fullframep1
You'd first need to select the letterboxed portions of your script (just threw in some random Trim values for demonstration purposes), crop off the bars with something like AutoCrop, then run it through SSU with a target size of DVwidepNTSC and an input pixel aspect of 10.0/11.0. PARin won't properly autodetect at this point since you've cropped off the borders, and the clip is no longer its original size.

Then, for the full frame content, trim to its extents and simply run it through SSU directly; with the full 720x480 available, the proper PAR of 10.0/11.0 will be applied automatically (though you could define it if you wanted, more on that in a moment).

Stitch them back together with + or ++, whichever is more appropriate in this case (I think +, but don't quote me on that), and you should be finished! For the first two parts, that is. You'd need to continue on with "letterboxp2" and so on.

The only problems are these: first, of course, it involves using Trim to select the various portions of your video by hand, which could be bothersome. I don't know of a better way to do it, unfortunately, since you want to crop-and-stretch some parts while padding others. Second, the value I gave above of 10.0/11.0 is the pixel aspect ratio of NTSC DV, and I can't say for sure whether or not that's correct for DVDs. If it turns out to be mistaken, though, you can always enter the correct value for PARin--also for PARout, if you're going back to DVD--and the cropping should take it into account properly.

If your DVD is not pure interlaced, you'll need to do any IVTC or other field matching work before using SimpleSlug, then pass the progressive clip in with prog=true, instead.

If you want interlaced output, you can use "DVwideiNTSC" instead, but I only just realized that's bottom field first only, while DVDs are usually top field first. Giving it a quick once over, I think I should be able to quickly throw in a parameter to let you select which field order you like. Give me a little while, I'll try it out.

This is part of my motivation for using two places after the decimal; releases can be much more granular now if I've overlooked something like this.

Done! Uploaded version 1.01, it now lets you choose a field order by way of 'interlaced', a string that can be either "tff" or "bff". If you want interlaced output for widescreen NTSC DVD, just use this:

Code:
SimpleSlugUpscale(size="DVwideiNTSC",interlaced="tff")

Last edited by Robert Martens; 6th November 2010 at 04:30.
Robert Martens is offline   Reply With Quote
Old 15th November 2010, 20:26   #19  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
I knew I'd need those extra decimal places. Updated to 1.02, with a handful of minor tweaks, but one big fix for box mode center dimensions that is the only reason I'm replying once again to this thread. A huge thank you to Nico Feragnoli for bringing the mistake to my attention!

While I was at it, I updated the preset PAL DV pixel aspect ratios after seeing henryho_hk's resizing script and realizing his values worked better than what I'd been using. Thanks, Henry!

Last edited by Robert Martens; 17th February 2011 at 08:34.
Robert Martens is offline   Reply With Quote
Old 15th December 2010, 07:34   #20  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
You are welcome, Robert. I've got to add customized PAR in my script too.

My avs2qxvid batch is using some more fancy PAR ratios that I found somewhere on the web.
henryho_hk is offline   Reply With Quote
Reply

Tags
qtgmc, resize, tempgaussmc, upscale

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 11:00.


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