Log in

View Full Version : Resize calculator PHP


Pages : 1 [2] 3 4 5

krosswindz
2nd April 2008, 17:53
Is there any link for the math if the source is BluRay/HD DVD?

smok3
2nd April 2008, 18:22
the hi-defs are mostly with square PAR i imagine (no i haven't seen the complete standard for either of this yet).

krosswindz
2nd April 2008, 18:41
^ I assume that they should be square, havent found any mention of them of not being square AFAIK.

SeeMoreDigital
2nd April 2008, 18:43
There are quite a lot of 1440x1080 sources knocking around, complete with 4:3 (PAR) aspect ratio signalling, creating a displayed shape of 1920x1080 pixels...

smok3
3rd April 2008, 09:33
some numbers are here;
http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
http://www.surrealroad.com/research/archives/2005/standard-data-resolutions/

DVCPRO HD (as i recall from hvx200) is either, using smaller res:
------------------------------------------------------
960x720 (square should be 1280x720), PAR is around 1.333 (so you can use hdv preset);
http://somestuff.org/resizeCalc.php?ssmw=960&sar=1&sar2=1.333&ssmh=720&CT=&CL=&CR=&CB=&trw=1280&dar=1&dar2=&mod=&padw=&padh=&css=&doit=true
or bigger res:
1280x1080 (square should be 1920x1080), PAR is around 1.5
http://somestuff.org/resizeCalc.php?ssmw=1280&sar=1&sar2=1.5&ssmh=1080&CT=&CL=&CR=&CB=&trw=1920&dar=1&dar2=&mod=&padw=&padh=&css=&doit=true
------------------------------------------------------
this needs to be confirmed (or denied).

p.s. hvx200 960x720 scaled to square 960x544 example (seems correct or very close):
http://somestuff.org/flashAVC/flvplayer_alt.php?moviename=movies/hvx200_raw_0013EO_mute-x960y544.mp4

08d
.added some examples and links (no math changes)

krosswindz
28th April 2008, 03:21
I am not sure but I am kind of revisiting the problem we had talked earlier. Now this was something that I see personally.

The movie DVD has been marked in the packaging with "aspect ratio 2.40:1"

With the cropping resize calc displays the DAR as 2.49

http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=&dar=1&dar2=&mod=&padw=&padh=&css=&doit=true

DVD has been authored by Sony, its probably one of the first sony dvd that I am backing up ever. My question would be why is there this difference?

smok3
28th April 2008, 07:51
various reasons:
1. sony is wrong
2. you are wrong by choosing wrong method somehow
3. my calc is wrong
did you try any alternative calc? or manual calc maybe?

SeeMoreDigital
28th April 2008, 09:20
I am not sure but I am kind of revisiting the problem we had talked earlier. Now this was something that I see personally.

The movie DVD has been marked in the packaging with "aspect ratio 2.40:1"

With the cropping resize calc displays the DAR as 2.49

DVD has been authored by Sony, its probably one of the first sony dvd that I am backing up ever. My question would be why is there this difference?Can you try this please: -

Play the DVD in a software player
Find a light scene where the black mattes are clearly visible.
Take a snapshot
Upload the snapshot to the forum

From the snapshot I should be able to tell you the movies aspect ratio...

smok3
28th April 2008, 11:08
08e
.internal release (last source code stays 08d), just some php fixes, lets see how it behaves before releasing the code.
08f
.added primitive unique visitors counter, some html fixes, sources are out

krosswindz
28th April 2008, 19:04
various reasons:
1. sony is wrong
2. you are wrong by choosing wrong method somehow
3. my calc is wrong
did you try any alternative calc? or manual calc maybe?

I normally use one of the two calculators, one is yours the other one being http://www.animemusicvideos.org/guides/avtech/resizecalc.html both spit out similar values, the difference being how the ar error is calculated.

Can you try this please: -

Play the DVD in a software player
Find a light scene where the black mattes are clearly visible.
Take a snapshot
Upload the snapshot to the forum

From the snapshot I should be able to tell you the movies aspect ratio...

Used vlc to grab these scenes, the movie is really dark so this is the best I could do. As you can see there is this white line on the top and bottom in many frames of this movie, I crop them off also along with the black border on the side before I back up.

http://img294.imageshack.us/img294/2069/vlcsnap5158296kp3.png

http://img293.imageshack.us/img293/9906/vlcsnap5157238tn8.png

http://img329.imageshack.us/img329/1601/vlcsnap5157467vh8.png

http://img152.imageshack.us/img152/2282/vlcsnap5157746tb7.png

http://img410.imageshack.us/img410/3081/vlcsnap46489bv3.png

http://img395.imageshack.us/img395/9950/vlcsnap46977sv1.png

http://img236.imageshack.us/img236/3937/vlcsnap47519rl3.png

http://img395.imageshack.us/img395/2095/vlcsnap47642bn4.png

http://img236.imageshack.us/img236/1571/vlcsnap47982fw8.png

http://img236.imageshack.us/img236/6792/vlcsnap48084cw1.png

SeeMoreDigital
28th April 2008, 19:46
Hi krosswindz,

Thanks for all the captures. After hard cropping the black mattes, green lines and image roll, your movie has an aspect ratio of 2.40:1 - as near as makes no difference.


Cheers

krosswindz
28th April 2008, 20:48
Hi krosswindz,

Thanks for all the captures. After hard cropping the black mattes, green lines and image roll, your movie has an aspect ratio of 2.40:1 - as near as makes no difference.


Cheers

Can you tell me what were the crop values.

Now the question is what went wrong with the math :confused:

krosswindz
28th April 2008, 22:00
This is one of the similar frame at 720x480 frame size

http://img209.imageshack.us/img209/7663/snapshot20080428224747lf0.jpg

basically I work on the cropping on this frame before resizing, now the question I have is the cropping that gets applied to this frame is it the same cropping that gets applied to the anamorphic frame size of 853x480.

The cropping I used was (2, 62, 0, -68)

EuropeanMan
28th April 2008, 22:38
^ as we discussed in PM kross...i was right. no offence...

my calculations were correct...your "backup" @ 2.50 was wrong...or rather AH's
-farooq

EuropeanMan
28th April 2008, 22:40
This is one of the similar frame at 720x480 frame size

http://img209.imageshack.us/img209/7663/snapshot20080428224747lf0.jpg

basically I work on the cropping on this frame before resizing, now the question I have is the cropping that gets applied to this frame is it the same cropping that gets applied to the anamorphic frame size of 853x480.

The cropping I used was (2, 62, 0, -68)

you can NOT apply the same A/R specifications on a 4:3 frame with one made on a 16:9 frame. those are two different specs. this movie was anamorphic and thus 16:9...you will have to use 853x480...as the pixels that are 'available'

in your 720x480 frame above...don't you see her face is vertically stretched? you can't do a proper a/r from this frame...

from MY understanding you must always calculate the source A/R from DAR frames...like ones shown on previous page.

krosswindz
28th April 2008, 22:56
^ as we discussed in PM kross...i was right. no offence...

my calculations were correct...your "backup" @ 2.50 was wrong...or rather AH's
-farooq

As for who is right or wrong I am not bothered. I am more interested in the math. That is what I care about.

you can NOT apply the same A/R specifications on a 4:3 frame with one made on a 16:9 frame. those are two different specs. this movie was anamorphic and thus 16:9...you will have to use 853x480...as the pixels that are 'available'

in your 720x480 frame above...don't you see her face is vertically stretched? you can't do a proper a/r from this frame...

from MY understanding you must always calculate the source A/R from DAR frames...like ones shown on previous page.

I believe using the source par it is possible to calculate the dar from the source video frame. I am sure there are other who would agree with this.

EuropeanMan
28th April 2008, 23:13
^ source DAR in this case from the source is the same as DVD packaging info.

on some bolly-titles, the .vobs have incorrect A/R on them inherently & are fixed in the .IFO files when they are played as a DVD...and even IF they are resized to a new A/R...then, many times it's wrong anyway as Bollywood DVD Authorors don't know how to properly do it :(

that's the sad part...we just got lucky with Sony here.

krosswindz
29th April 2008, 03:59
Are these PAR values correct, these are different from what is used in resizeCalc

PAL: 128:117
NTSC: 10:11
PAL Wide: 118:81
NTSC Wide: 40:33

smok3
29th April 2008, 07:25
as EuropeanMan said, visualy this appears as 2:40, however there is no much wrong watching it at 2:50 (dunno) - it seems you would never get correct numbers by using the calc or screenshot method.

40:33 = 1.21212 = 16/9*480/704 wont give much different results as it seems, calc still says that DAR is 2.48 something.

a. this seems correct:
http://somestuff.org/resizeCalc.php?ssmw=704&sar=1.215&sar2=&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
(imagine that 704 is actually 720, which means they are using the fullscreen 'standard')
or with some clicking (converting 704 to 720) you would get 1.189 PAR for the fullscreen NTSC 'standard'.
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.189&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
(but that number is not mentioned anywhere else as i remember)

b. or adobe seems to use 1.2 for ntsc wide (16/9*486/720), which again is close
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.2&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
what a mess...

btw: the calc got incredible 22 unique visitors since yesterday :P

SeeMoreDigital
29th April 2008, 08:59
The following sample was "hard cropped" to 850x352 pixels and then encoded to an 720x352 frame with 32:27 aspect ratio signalling added: -

http://www.sendspace.com/file/ytnm9y


See what you think?

smok3
29th April 2008, 09:43
SMD: The connection to the server was reset while the page was loading.

08g - nothing new with resizing, i'am playing with the counter...
.faster and even simpler ('unique' visitors) counter, behaves like: store last (and only last) ip and use session (cookie) as well, (can be faked by killing the cookies and waiting for another guy to hit the page before you or by changing the ip as well - so with two machines on different ips one could play the ping-pong and increase the count).

smok3
29th April 2008, 11:17
krosswindz: could you post a small vob sample? (if you need some ftp let me know.)

krosswindz
29th April 2008, 13:32
The following sample was "hard cropped" to 850x352 pixels and then encoded to an 720x352 frame with 32:27 aspect ratio signalling added: -

http://www.sendspace.com/file/ytnm9y


See what you think?

It seems fine.

as EuropeanMan said, visualy this appears as 2:40, however there is no much wrong watching it at 2:50 (dunno) - it seems you would never get correct numbers by using the calc or screenshot method.

40:33 = 1.21212 = 16/9*480/704 wont give much different results as it seems, calc still says that DAR is 2.48 something.

a. this seems correct:
http://somestuff.org/resizeCalc.php?ssmw=704&sar=1.215&sar2=&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
(imagine that 704 is actually 720, which means they are using the fullscreen 'standard')
or with some clicking (converting 704 to 720) you would get 1.189 PAR for the fullscreen NTSC 'standard'.
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.189&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
(but that number is not mentioned anywhere else as i remember)

b. or adobe seems to use 1.2 for ntsc wide (16/9*486/720), which again is close
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.2&ssmh=480&CT=62&CL=2&CR=0&CB=68&trw=851&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
what a mess...

btw: the calc got incredible 22 unique visitors since yesterday :P

Assuming that we have full frame (NTSC Wide) anamorphic video when we convert to square pixel we should get 853x480 if we use mod1.

using NTSC Wide PAR
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=&ssmh=480&CT=0&CL=0&CR=0&CB=0&trw=853&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true

Using 1.189 as PAR
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.189&ssmh=480&CT=0&CL=0&CR=0&CB=0&trw=853&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true

Using 1.2 as PAR
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=1.2&ssmh=480&CT=0&CL=0&CR=0&CB=0&trw=853&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true

But 1.189 doesnt seem to be a PAR for NTSC Wide mentioned any where

http://en.wikipedia.org/wiki/Pixel_aspect_ratio

IMO if we have the right PAR value we should be able to get to right anamorphic width.

krosswindz: could you post a small vob sample? (if you need some ftp let me know.)

http://www.mediafire.com/?3dmyzdfcvj4

smok3
29th April 2008, 14:08
yes, but check the square numbers, the ones i use for PAL are
1024x576 square
http://somestuff.org/resizeCalc.php?ssmw=1024&sar=1&sar2=&ssmh=576&CT=0&CL=0&CR=0&CB=0&trw=704&dar=1.459&dar2=&mod=1&padw=&padh=&css=&doit=true

and
1050x576 square
http://somestuff.org/resizeCalc.php?ssmw=1050&sar=1&sar2=&ssmh=576&CT=0&CL=0&CR=0&CB=0&trw=720&dar=1.459&dar2=&mod=1&padw=&padh=&css=&doit=true

krosswindz
29th April 2008, 14:59
I dont have much idea about PAL but it seems right, I am sure that NTSC would be the same way around too. Looking at the standards it seems that this should be the way it should be done.

To further confuse oneself NTSC Wide is displayed as 853x480 and PAL Wide 1024x576. This is what it is displayed as. Do we have to account for PAR in this case?

smok3
29th April 2008, 15:03
edit: nm, my mistake

back to your sample, this seems to be one way of getting the 'on the box' DAR
http://somestuff.org/resizeCalc.php?ssmw=704&sar=1.215&sar2=&ssmh=480&CT=60&CL=2&CR=0&CB=66&trw=&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true or
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1.215&sar2=&ssmh=480&CT=60&CL=10&CR=8&CB=66&trw=&dar=1&dar2=&mod=1&padw=&padh=&css=&doit=true
however i don't think it is correct for this specific sample, now what is puzzling me is that the player seems to get it right...., is it because the software player is wrong or... -> and we are back at the start.

krosswindz
29th April 2008, 15:35
The only thing I can think of is probably what something sony did. They probably authored it at 704x480 and then stretched to 720x480. Software players guess only check if it is either 4:3 or 16:9. If this is the case then it is a violation of standards IMO.

smok3
29th April 2008, 15:41
yes, it appears so, but iam afraid to claim anything really :)

for example, if i use my 'out of the air' number i get close as well (with DAR)
http://somestuff.org/resizeCalc.php?ssmw=720&sar=1&sar2=1.189&ssmh=480&CT=60&CL=2&CR=0&CB=66&trw=&dar=1.215&dar2=&mod=1&padw=&padh=&css=&doit=true

krosswindz
29th April 2008, 16:34
I am not making any claims either but this seems to be the only logical explanation to it. The "out of the air" number isnt a valid PAR IMO. It would be interesting if this can be checked with some PAL DVDs or other NTSC DVDs.

edit: Will try it with the few DVDs that I have.

smok3
29th April 2008, 17:02
maybe better check the entire cycle;
http://somestuff.org/downloads/resizeCalc_php/test_pat/
(i think all you need is this simple test pat picture, the circle should be circle at the end of its path)

krosswindz
29th April 2008, 17:23
The test pattern seems to be 4:3 only, a few more test pattern that can be used to test the math.

http://img139.imageshack.us/img139/2696/nbc640x480bw8.gif

http://img149.imageshack.us/img149/930/indianhead640x480lx0.gif

http://img301.imageshack.us/img301/7177/bbcgts4.jpg

http://img291.imageshack.us/img291/2672/bbcf1997hl9.jpg

http://img292.imageshack.us/img292/3994/bbcaxo7.gif

http://img329.imageshack.us/img329/6969/aspectratiocircles1024xrp9.jpg

Not sure if there are any 16:9 test pattern. There should be since now there are 16:9 TVs.

krosswindz
29th April 2008, 17:28
found 16:9 test pattern this should be interesting to see how it works.

http://img216.imageshack.us/img216/3075/16x9testpatternpa3.gif

smok3
29th April 2008, 18:08
you can/should make it wide, example;

pal704wide
imageSource("philips_test_pat.png")
assumefps(25)
Subtitle("pal704Wide", font="arial", size=50, text_color=$ffffff, align=5)

# resizeCalc
# pixels = 304128, DAR error = -0.042
# Crop(Left, top, -right, -Bottom)
Crop(0,2,-0,-0) # 768,574
LanczosResize(528,576) # mod16
AddBorders(88,0,88,0) # pad width 704


#http://somestuff.org/resizeCalc.php?ssmw=768&sar=1&sar2=&ssmh=576&CT=2&CL=&CR=&CB=&trw=528&dar=1.459&dar2=&mod=&padw=704&padh=576&css=&doit=true

edited

krosswindz
29th April 2008, 18:46
http://img166.imageshack.us/img166/3076/pal704widerx3.png

this is the output screen of the script.

will try to encode into mkv and see how it works.

smok3
29th April 2008, 18:50
i guess, now the idea is to measure the circle in pixels before and after dvd has happened, if i force preview in virtualdub to 16:9, this will be correct.

krosswindz
29th April 2008, 18:56
It seems perfect when I force it to 16:9 now the question is what would be a similar test for NTSC

http://img410.imageshack.us/img410/1180/testkg8.jpg

smok3
29th April 2008, 19:00
for ntsc704wide version, and change assumefps to whatever you need for the ntsc, 29.something?

#http://somestuff.org/resizeCalc.php?ssmw=768&sar=1&sar2=&ssmh=576&CT=2&CL=&CR=&CB=&trw=528&dar=1.215&dar2=&mod=&padw=704&padh=480&css=&doit=true

krosswindz
29th April 2008, 19:26
Seems to me like that it works fine, for some reason 40:33 aspect ratio for NTSC seemed better visually to me than 16:9. I am not sure if you notice the same.

smok3
29th April 2008, 19:36
what/how exactly did you test?

krosswindz
29th April 2008, 19:41
I opened the avs file in virtualdub and changed the aspect ratio in that from free adjust to 16:9 or 40:33.

krosswindz
29th April 2008, 20:04
@smok3 that was my bad, 704 looks perfect with both 16:9 and 40:33, I tried another one with padding it to 720 and that also seems better for 16:9, 40:33 makes it horizontally stretched.

The conclusion we have from this is that the PAR values are correct IMO. The question comes what went wrong with that DVD. I have a couple of other DVDs which I am gonna check.

smok3
29th April 2008, 20:09
here is one thread, that should be interesting
http://forum.doom9.org/showthread.php?t=132378

SeeMoreDigital
29th April 2008, 20:11
Seems to me like that it works fine, for some reason 40:33 aspect ratio for NTSC seemed better visually to me than 16:9. I am not sure if you notice the same.Yep... That's because 704 x 40/33 = 853.3333.

If you had elected to encode a 720x480 resolution frame, you would need to add aspect ratio signalling of 32:27. As 720 x 32/27 = 853.3333.


Cheers

krosswindz
29th April 2008, 20:28
coming back to the point, what would be the right value that one should pick up when one is doing a mpeg-4 encode from DVD. What would be the right way to calculate the actual DAR.

One would surely start of by cropping the black borders on the top & bottom, and the sides. And depending on if the source is 720x or 704 would we choose the 40:33 or 32:27 to calculate the DAR?

SeeMoreDigital
29th April 2008, 20:46
coming back to the point, what would be the right value that one should pick up when one is doing a mpeg-4 encode from DVD. What would be the right way to calculate the actual DAR.

One would surely start of by cropping the black borders on the top & bottom, and the sides. And depending on if the source is 720x or 704 would we choose the 40:33 or 32:27 to calculate the DAR?For NTSC sources. If you crop/re-size to 704 wide use 40:33. Or if you crop/re-size to 720 wide use 32:27. Both will give you a "playback" width of 853.3333 pixels.

krosswindz
29th April 2008, 21:19
For NTSC sources. If you crop/re-size to 704 wide use 40:33. Or if you crop/re-size to 720 wide use 32:27. Both will give you a "playback" width of 853.3333 pixels.

The point is that if the DVD source is 704 pixels width-wise or 720 pixels width-wise when resizing after cropping what would one choose as the PAR to calculate the DAR. This would be the DAR to be used for the mpeg4 encode.

going with the formula for DAR.


DAR height
------ = ----------
PAR width

SeeMoreDigital
29th April 2008, 22:03
The point is that if the DVD source is 704 pixels width-wise or 720 pixels width-wise when resizing after cropping what would one choose as the PAR to calculate the DAR. This would be the DAR to be used for the mpeg4 encode.

going with the formula for DAR.


DAR height
------ = ----------
PAR width
At the end of the day, DAR, PAR and SAR are only different abbreviations that use the same maths to calculate a required "aspect ratio signalling" value!

Don't get caught up in the abbreviations... Just do the maths ;)

krosswindz
29th April 2008, 22:29
At the end of the day, DAR, PAR and SAR are only different abbreviations that use the same maths to calculate a required "aspect ratio signalling" value!

Don't get caught up in the abbreviations... Just do the maths ;)

What would you propose would be the math to do calculate "aspect ratio signalling" value?

Given that the source could be a DVD either NTSC/NTSC Wide/PAL/PAL Wide with video frame size as 704x480/720x480/704x576/720x576.

SeeMoreDigital
29th April 2008, 22:40
Have a look at the following thread: -

http://www.ziova.com/forum/index.php?showtopic=3800

Together with the ARS Calculator...

http://img233.imageshack.us/img233/9139/arscalculator9va.png


Cheers

krosswindz
29th April 2008, 23:00
Have a look at the following thread: -

http://www.ziova.com/forum/index.php?showtopic=3800

Together with the ARS Calculator...

http://img233.imageshack.us/img233/9139/arscalculator9va.png


Cheers

I did read that the, one relation ship I didnt understand just by looking at is the relation between PFS, MAR and ARS?

edit:
What I am trying is to have one shot calculator so that I really dont have to worry about multiple calculators.

edit2:
The reason being I normally encode to square PAR.