Trying to resize and upscale correctly a PAL DVD source...

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
User avatar
Snowcrash
Joined: Thu Jun 19, 2008 5:08 am
Status: Looking for a job T_T
Location: France
Org Profile

Trying to resize and upscale correctly a PAL DVD source...

Post by Snowcrash » Wed Feb 09, 2011 10:19 am

Ok guys I got few questions for you. Before to start, I have already read the Org guide several times.

My source is an european anime that I got from a DVD. So no problem about the framerate, I keep it at 25 fps.

I rip it, dgindex it and now I am working on it with AvsPmod.

Code: Select all

mpeg2source("D:\ONYX\Cliches.d2v")
1. Deinterlacing

DGindex told me it was Interlaced. But when I checked the source with virtualdub frame per frame, it doesn’t seem interlaced. I did an analysis with the tool in MeGu (AVS script creator)i, it said it’s progressive but I don’t trust so much this tool.
I checked the VOB as well with The KMplayer an dit confirms it’s interlaced «Bottom Field First ».
Spoiler :
Image
So right, I used :

Code: Select all

mpeg2source("D:\ONYX\Cliches.d2v")
Tdeint()
2. Cropping and resizing

That’s my big problem. It’s anamorphic PAL. It should be easy with this script :

Code: Select all

mpeg2source("D:\ONYX\Cliches.d2v")
Tdeint()
Spline36Resize(1024,576)
But there are 2 black borders I want to crop first :

Code: Select all

mpeg2source("D:\ONYX\Cliches.d2v")
Tdeint()
ConvertToRGB (cause I want to crop even number)
Crop(0, 13, -2, -11)
The new resolution is : 718x552
Now I need to resize it to get an anamorphic ratio (16/9) without ratio error. I used the resizer included in AvsPmod but I am not sure how to use it correctly. The pixel apect ratio comes from the d2v file.
Image

So I got this new ratio which is the closest to 576p :
1008x544 (with a 0,16% error)

But I don’t want this resolution, I’d like to get a standard resolution like 1024x576. I need some help to get correct resolutions and ratio. I suppose I need to upsacle, then crop the right and left borders ?

At this point this is my script :

Code: Select all

mpeg2source("D:\ONYX\Cliches.d2v")
Tdeint()
ConvertToRGB
Crop(0, 13, -2, -11)
Spline36Resize(1024, 576)
ConvertToYV12()
But in this way I got a ratio error : the width is larger than it should be. It’s not really a bad deal, maybe I will keep it if I want to have the complete image.

3. Upsacle and cleaning
If I want to upscale my source at 1280x720, what script I should use ? Does it worth to do it ?

I am not very good at cleaning my source with avisynth, so I use the filter 2d_cleaner_optimized (Jim Casaburi) but maybe is there a way to use it in AVS ?

Image

Here are my results with VirtualDub:

Before:
Spoiler :
Image
The source is usually very clean but some motion sequences have some pixels blocks.
After:
Spoiler :
Image
Thanks in advance for your help
Image

User avatar
Cannonaire
Joined: Wed May 05, 2010 5:59 pm
Status: OVERLOAD
Location: Oregon
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Cannonaire » Wed Feb 09, 2011 4:47 pm

I don't really have the time right now to help with cleaning it up, but I will say that I don't think that's the best way to clean it. You're losing a lot of detail even though it appears to be taking away the noise. I bet someone else will help you with that soon enough though.

I can help with the aspect ratio I think. Try this line:

Code: Select all

Spline36Resize(1024, 576, src_left=9, src_top=0, src_width=702, src_height=576)
If there are still borders, crop the image AFTER you resize. The reason I picked these numbers specifically are to make sure you are starting with the active picture area and have correct image geometry. If you still must upscale, be sure and pick a 16:9 resolution before cropping to maintain correct geometry. Resizing the 1024x576 to 1280x720 would work, but make sure you deinterlace first or it will look awful.

Just a note, because the spline36resize line I gave you is cropping 9 pixels off of each side to begin with and then resampling to give you a higher resolution, it is not necessary to change your colorspace to RGB. Keeping it YV12 should be fine. You can also tweak the src_left value if one side has bigger borders than the other; just be sure to keep src_width at 702.

I got the numbers for pal active picture area here:
http://ps-auxw.de/cgi-bin/ar-calc.pl
Image Think millionaire, but with cannons. || Resident Maaya Sakamoto fan.

Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Mister Hatt » Sat Feb 12, 2011 5:41 am

I also lack time, but both MeGUI and KMP are terrible ways to figure out what your source is. KMP also violates the GPL, and while I don't agree with the nature of this license, I do think KMP should never be used by anyone and the creator should go bankrupt.

As to your problem, your first issue is you have no idea how interlacing vs interlaced coding work. Upload a sample and someone will be able to tell you if it really is interlaced. Secondly, you are converting to RGB for no good reason, don't do that. Upscaling is never worth it so ignore that as well. For your aspect and cropping/resizing stuff, check out http://ps-auxw.de/cgi-bin/ar-calc.pl, it should give you some pretty comprehensive info that you can just copy and paste.

User avatar
Snowcrash
Joined: Thu Jun 19, 2008 5:08 am
Status: Looking for a job T_T
Location: France
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Snowcrash » Sat Feb 12, 2011 10:07 am

Thanks for your answers, guys.

So I uploaded a sample to have an idea what is my source.
http://www.mediafire.com/?4sb6kat9dcm804l

I think honestly it's interlaced according to DGindex even if we can't see some lines or whatever.

About Cropping:

I need to crop the top and the bottom of the image because there are black borders there.
- 13 at the top
- 11 at the bottom
In YUV color area, we can't crop with even number, that's why I convert to RGB color area. But if I can avoid it without to have cropping 14 top pixels and 12 bottom pixels (I want to keep the maximum of original image), it could be better.

For resizing it's quiet complex because if I follow Cannonaire's advice, the size and ratio will be correct (1024,576) of course but I will need to crop top and bottom after --> the height won't be 576p anymore.

Anyway I am waiting for your replies with the sample I gave to you ;)
Image

User avatar
mirkosp
The Absolute Mudman
Joined: Mon Apr 24, 2006 6:24 am
Status: (」・ワ・)」(⊃・ワ・)⊃
Location: Gallarate (VA), Italy
Contact:
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by mirkosp » Sat Feb 12, 2011 3:23 pm

spline36resize(width,height,cropleft,croptop,-cropright,-cropbottom) to crop odd amounts.
Image

Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Mister Hatt » Sat Feb 12, 2011 3:55 pm

What mirko said. Also you're associating YUV with YV12 in your mind. In reality, YV12 is a subset of YUV. YUV itself can be cropped in odd amounts if you want, the colourspace this works for is YV24 or higher. The only reason YV12 forces you to crop evenly is that it subsamples in blocks of 2x2. If you ignore chroma, cropping mid-sample shouldn't be a problem either. Somewhat related, keeping the maximum amount of the image isn't a big deal and overcropping is usually the better way to go unless you put far more trust in spline36 than I choose to.

User avatar
Cannonaire
Joined: Wed May 05, 2010 5:59 pm
Status: OVERLOAD
Location: Oregon
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Cannonaire » Sun Feb 13, 2011 3:20 pm

mirkosp wrote:spline36resize(width,height,cropleft,croptop,-cropright,-cropbottom) to crop odd amounts.
That won't work exactly. Spline36Resize(width, height, cropleft, croptop, [source width starting from left crop], [source height starting from top crop])
Say you want to crop your source to 702x576 then resize to 768x576, you would use Spline36Resize(768, 576, cropleft, croptop, 702, 576)

I think the main point I'm trying to stress though is that for PAL, if you want correct Pixel Aspect Ratio, crop it to 702x576 (crop however you want on the sides, so long as it's 18 total off) and resize it, then crop again after to remove the junk and black bars. When you do your first crops in the resize line, you can crop odd amounts and even use float values (something like 1.337 pixels off one side, though I wouldn't recommend it in this case).

I also don't see any reason for 576p to be required; a lot of videos you see online are non-standard resolutions and it makes even less sense for it to be strictly 576p if it's not also going to be DVD PAR. A far as upscaling, I wouldn't recommend it unless you're mixing it with a higher resolution source or if for some reason a convention requires a certain resolution.
Image Think millionaire, but with cannons. || Resident Maaya Sakamoto fan.

User avatar
Cannonaire
Joined: Wed May 05, 2010 5:59 pm
Status: OVERLOAD
Location: Oregon
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Cannonaire » Sun Feb 13, 2011 3:34 pm

Sorry for the double post, but since you specified the top and bottom crop numbers already, try these lines:

Code: Select all

Spline36Resize(1024, 552, [crop from left], 13, 702, 552)
Crop(cropleft, 0, -cropright, -0)
With cropleft and cropright however much you need to remove the junk. It is generally better to overcrop than to leave junk and borders.

The screenshots you posted don't actually have much detail, but if you look at the lines in the wood on the floor you can see that the filter in Virtualdub is killing what little detail is there. Denoisers can be a pain sometimes, but you might try using FFT3dfilter at a low setting. I guess there are a few versions floating around with different parameters, so I can't tell you the exact settings to use, but you should be able to fix the problems with a fairly low value on that filter. People have a tendency to grossly over-filter things, so when you find a value that you think fixes the problem, it might be a good idea to dial it back a bit.

If you're feeling particularly masochistic, you can always try the filter I like to use. It's called MCTemporalDenoise. It takes a lot of searching and setup to get running, and it's glacially slow to run, but the results can be stunning. If you decide to go this route, feel free to ask me for advice/filters necessary to get it working.
Image Think millionaire, but with cannons. || Resident Maaya Sakamoto fan.

Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by Mister Hatt » Mon Feb 14, 2011 6:26 am

It actually just recycles MPlayer's cropping in that regard >___>

User avatar
mirkosp
The Absolute Mudman
Joined: Mon Apr 24, 2006 6:24 am
Status: (」・ワ・)」(⊃・ワ・)⊃
Location: Gallarate (VA), Italy
Contact:
Org Profile

Re: Trying to resize and upscale correctly a PAL DVD source.

Post by mirkosp » Mon Feb 14, 2011 6:59 pm

Cannonaire wrote:
mirkosp wrote:spline36resize(width,height,cropleft,croptop,-cropright,-cropbottom) to crop odd amounts.
That won't work exactly. Spline36Resize(width, height, cropleft, croptop, [source width starting from left crop], [source height starting from top crop])
Say you want to crop your source to 702x576 then resize to 768x576, you would use Spline36Resize(768, 576, cropleft, croptop, 702, 576)
It actually works both ways. Normal crop works both ways too. It really is the same, eh, you could say that using negative values just does the math for you, that's all.
Image

Locked

Return to “AviSynth Help”