PDA

View Full Version : Trying to figure why this works?


ritmo2k
11th January 2002, 00:49
Why does this script work?
I just cant see the correlation!
I have an old 16x9 - 720x480 non anamorphic dvd, and why does this make a perfect vcd? I cant understand the reasoning, as i am about to start a few 2.35:1 movies, and some anamorphic dvds, and i would like to be able to write my script to resize, chop the black bars of it, encode it, then add my own in cce with an avs script. But since I dont understand how this works, I cant get the figures right!

LoadPlugin("~~\mpeg2dec.dll")
mpeg2source("~~\~~.d2v")
BiCubicResize(352,180,0.333,0.333)
AddBorders(0,30,0,30)
ResampleAudio(44100)

Thanks,

western shinma
11th January 2002, 01:06
Did you miss my last post in the other thread? Here it is again:

I don't personally think it is necessary to crop the sides for VCD/SVCD. As for resize calculations, you might try thinking of the horizontal resolution as 320 to make things easier. Of course you will still be encoding at 352x240, but this works because of VCD's nonsquare pixels.

Here's what I might do with your cropping example: (Just make sure you have an even number of horizontal and vertical pixels when you do this for real.)

715/720*640=636
479/480*360=359
359/636*320=181

(I didn't show the decimals here, but I did use them in the calculations.)

So in this case you could resize to 352x181 and crop 30 and 29 off the top and bottom. You might get better quality from using 352x176 in either case, since then you won't have a black border in the middle of a macroblock. If you want to try this you might consider simply cropping a couple rows rather than resizing so your aspect ratio is the same.

If you already read this and still need help just let me know what you need clarified.

ritmo2k
11th January 2002, 02:52
You cant imagine how much help you have been, but I am just unsure.
I had a whole bunch of the other Q's in the last thread.

But i am just confused here! Where does the 640 and 360 come from?
Also why are you able to use 320? Bottom line is maybe I just dont understand how all this works. What is the correlation to 16x9 and 720*480? I guess this is why I dont get converting it to 352*240 and 4x3!

Maybe you can shed light there so i can make sense. How does a svcd have 480x480? Does the lines of res have nothing to do with aspect ratio?

Totally puzzled,

western shinma
11th January 2002, 03:12
Yeah, I left a few things out. This probably isn't the most technically correct method, but it works. If someone else has a better method, please share it with us. :)

Basically, just ignore the horizontal resolution. 640x480 is 4:3, so that is where that came from (there are 480 vertical lines on the DVD of course). Since the target aspect ratio is 16:9 however I used 360 for the vertical. Really though this number is just a starting point. It would probably be less confusing to just use 16 and 9 instead:

715/720*16=15.889
479/480*9=8.981
240*4/3=320 (240 is the target vertical resolution)
8.981/15.889*320=181

OK, that should be pretty clear now. Let me know if you've got any more questions.

western shinma
11th January 2002, 03:18
Originally posted by ritmo2k
But i am just confused here! Where does the 640 and 360 come from?
Also why are you able to use 320? Bottom line is maybe I just dont understand how all this works. What is the correlation to 16x9 and 720*480? I guess this is why I dont get converting it to 352*240 and 4x3!
On a DVD, 720x480 is either 16:9 or 4:3, depending on how it was made. To make it look correct, the player resizes the picture automatically. If you play a 16:9 DVD on your computer for example, it is displayed at somewhere around 848x480. DVD2AVI doesn't do this, however, so it is easy to get confused.
Maybe you can shed light there so i can make sense. How does a svcd have 480x480? Does the lines of res have nothing to do with aspect ratio?
Same thing here, it is resized to 640x480 during playback.

ritmo2k
11th January 2002, 03:34
So how do I come up with the avs commands for a anamorphic vcd, and a cinema scope dvd?

Starting to get it...

western shinma
11th January 2002, 04:53
First of all, I highly suggest not to use 2.35:1 for VCD, unless you think 136 lines of vertical resolution is OK. This is going to be even more confusing, but for cinemascope you can crop off the sides and convert it to 16:9. To do this conversion, 90 pixels need to be cropped from either side.

But I won't get into that further unless you are interested in trying it out. For 16:9, just follow the basic setup I used a couple posts back:

cropped horizontal/720*16=x
cropped vertical/480*9=y
240*4/3=320 (240 is the target vertical resolution)
y/x*320=resized vertical

Then use AddBorders to letterbox. If you aren't cropping, you really don't need any calculations, just always use 352x180 or 352x176 for better compression.

ritmo2k
11th January 2002, 06:23
Yea, i get the cinemascope thing, its so much longer then a std. 16*9 so I see why you might crop off a bit. That makes sense!

Where I am at is just trying to reason your math out.
I will look more at it in a sec.

As for you saying "...352x180 or 352x176 for better compression."
Why does 352x176 give better compression? What sideffects happens when you do ti that way? Do you then have to compensate w/ addborders to make up the diff?

I guess if you could just detail your logic in the math you used, I would happy! I wanna be able to understand it so I can make changes and be able to tackle any job that comes my way!

Thank you so much for your time!

ritmo2k
11th January 2002, 06:41
I am looking at dvd2svcd's avs for the same 16*9 dvd.

BiCubicResize(480,360,0.00,0.75)
AddBorders(0,60,0,60)

How does this work? I cant correlate it to your math?
I am gonna starte at it later when I am not so tired ROTFLMAO,
You are gonna shoot me, HAHAH

Ill get back after I put more time...

Thank you!!

western shinma
11th January 2002, 07:07
Sure it works.

480*4/3=640 (480 is the target vertical resolution)
9/16*640=360

176 would give better compression because the borders between the black bars and the actual video won't be in the middle of a macroblock. This should reduce artifacts at the borders as well as leave more bits for describing the rest of the video.

Edit: I'll try to explain what I did. Let's just look at the simpler uncropped calculation in this post. Basically, like I said ignore the horizontal resolution and just use the vertical. First you find 4/3 of your vertical, which is 640 in this case. This is a sort of imaginary horizontal resolution just used for doing the math. 9/16 of that is what you resize the vertical to. The fractions come from the 4:3 aspect ratio (after you add the bars) and the 16:9 without the bars.

ritmo2k
11th January 2002, 08:00
I set up an excel sheet, and now I see it!

Now whats a macroblock? Thats the only thing I dont get?
Also, what is this 16x16 pixel mpeg thing? ie you can only cut in chunks of 16? What am i talking about here, i read this somewhere.

If it helps, my flix doesnt have any black bars eoncoded in it.
It is an old godfather dvd. So does all the other aspet ratios like 1.85:1 and 2.35:1 have the black bars actually in the movie to make it a 16*9 dvd when its image really is not?

Thanks!!!

western shinma
11th January 2002, 09:56
The 16x16 blocks is the thing I was talking about. It isn't the end of the world if your borders and video aren't multiples of 16, but it usually improves video quality.

The bars I mentioned are the ones you are adding. Most 16:9 movies actually don't have black bars, they are just added during playback. Wider aspect ratios have them both encoded as part of the video as well as the automatically generated ones.

ritmo2k
11th January 2002, 10:28
So would that mean cropping off 2 here and 3 there would slightly detriment the quality?

Also, I borrowed my friends Final Fantasy DVD.
It is anamorphic. I ripped a chapter out, and did some tests.

DVD2SVCD uses an avs script thats exactly the same as the one for the non anamorphic true 16*9 dvd I have. Is that right?
BiCubicResize(480,360,0.00,0.75)
AddBorders(0,60,0,60)

Since its a diff aspect ratio, shouldnt we modify your parameters you showed me? It looks ok, but then again, when a movie is slightly off, you cant tell! How do i find out what aspect ratio it truely is?

Thanks,

ritmo2k
11th January 2002, 10:49
So would that mean cropping off 2 here and 3 there would slightly detriment the quality?

Also, I borrowed my friends Final Fantasy DVD.
It is anamorphic. I ripped a chapter out, and did some tests.

DVD2SVCD uses an avs script thats exactly the same as the one for the non anamorphic true 16*9 dvd I have. Is that right?
BiCubicResize(480,360,0.00,0.75)
AddBorders(0,60,0,60)

Since its a diff aspect ratio, shouldnt we modify your parameters you showed me? It looks ok, but then again, when a movie is slightly off, you cant tell! How do i find out what aspect ratio it truely is?

Thanks,

western shinma
11th January 2002, 11:31
So you're doing SVCD now?

As long as you don't do any cropping, you should always be able to resize 16:9 DVDs to 480x360 and get the same aspect ratio that was on the DVD.

Edit: your last disc was nonanamorphic? In that case you probably would have been fine with a simple resize to 480x480 instead of cropping/resizing/adding borders.

Anamorphic does not imply 2.35:1, so I missed the part about the different aspect ratios. If it is 2.35:1 resizing to 480x360 will still be fine, since the DVD will already have borders to fill in the space between 360 and the video.

ritmo2k
11th January 2002, 11:42
Yea, i am all over the place like a dogs wang!
I like svcds of course, but dont like getting up every few minutes to pop in a cd!

I understand this now reasonably well. The only thing left is the diff between 16*9, 1.85:1, and 2.35:1. Final fantasy is not 16*9, its iether 1.85:1, or 2.35:1. Thing is, I dont see the black lines encoded into the movie. Why does resize (no cropping done) with the same parameters work? If its not really 16*9, why do those calcs for vcd or svcd work?

Thats all I guess I am unclear on now!

If you say there are black bars encoded into the movie on a 2.35:1 film, is that how they get it back at 16*9?

I am almost there buddy!

western shinma
11th January 2002, 13:27
With a 2.35:1 film, there should be around 60 black lines on the top and the bottom of the movie, which you could crop off if you'd like, but it is probably simpler to just leave them in and add more blank lines.

Here are the two methods:

Crop(0,60,720,360)
BicubicResize(480,272)
AddBorders(0,104,0,104)

or

BicubicResize(480,360)
AddBorders(0,60,0,60)

The second method works just as well because there should still be about 44 lines of blank space on the top and bottom of the resized video. I prefer the first method however, because sometimes the black bars on the DVD aren't quite black. It should also be slightly faster since the resize filter won't be wasting time on black bars.